From 4b34bbadf9f27329e63a6ba23ecb452954ebbbc0 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 5 May 2015 16:01:30 -0600 Subject: [PATCH 1/3] Merge pull request #1098 from WouterSioen/fix-typo Fix typo --- docs/04-Polar-Area-Chart.md | 4 ++-- src/Chart.PolarArea.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/04-Polar-Area-Chart.md b/docs/04-Polar-Area-Chart.md index 658da54fc..016a45f3c 100644 --- a/docs/04-Polar-Area-Chart.md +++ b/docs/04-Polar-Area-Chart.md @@ -83,7 +83,7 @@ These are the customisation options specific to Polar Area charts. These options //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 @@ -169,4 +169,4 @@ Calling `removeData(index)` on your Chart instance will remove segment at that p ```javascript myPolarAreaChart.removeData(); // Other segments will update to fill the empty space left. -``` \ No newline at end of file +``` diff --git a/src/Chart.PolarArea.js b/src/Chart.PolarArea.js index 1b7aac3ff..c220a6f4b 100644 --- a/src/Chart.PolarArea.js +++ b/src/Chart.PolarArea.js @@ -28,7 +28,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 @@ -266,4 +266,4 @@ } }); -}).call(this); \ No newline at end of file +}).call(this); From cf07df07d6d7fa155a9f40661417ac27853adeac Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 8 May 2015 16:20:21 -0600 Subject: [PATCH 2/3] Bar Attempt # 4 --- samples/bar.html | 2 + src/Chart.Bar.js | 146 ++++++++++++++++++++-------------------------- src/Chart.Core.js | 52 +++++++++-------- 3 files changed, 91 insertions(+), 109 deletions(-) diff --git a/samples/bar.html b/samples/bar.html index c386c50fa..5146660b8 100644 --- a/samples/bar.html +++ b/samples/bar.html @@ -50,6 +50,8 @@ 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 8127d520a..385131acc 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 + + //Create a new point for each piece of data helpers.each(this.data.datasets,function(dataset,datasetIndex){ - - helpers.extend(this.datasets[datasetIndex], { - label : dataset.label || null, - fillColor : dataset.fillColor, - strokeColor : dataset.strokeColor, - }); - + 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.scale.update(); - // Reset any highlight colours before updating. - helpers.each(this.activeElements, function(activeElement){ - activeElement.restore(['fillColor', 'strokeColor']); - }); - - this.eachBars(function(bar){ + 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(); + 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 d0a70336d..68f87df9a 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 3/3] Bar attempt #5 --- src/Chart.Bar.js | 94 +++++++++++++++++++++-------------------------- src/Chart.Core.js | 77 ++++++++++++++++++++++---------------- 2 files changed, 88 insertions(+), 83 deletions(-) diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index 385131acc..0bd7b7e6b 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); - - 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 - }); - 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); - + // 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.scale.endPoint, + }); + // Copy to view model + bar.save(); + }, this); + + this.update(); + }, + 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, 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 68f87df9a..bb8f3ece9 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); } },