From: Tanner Linsley Date: Fri, 15 May 2015 23:07:41 +0000 (-0600) Subject: inGroupRange function for bar charts label mode X-Git-Tag: v2.0-alpha~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09c11440dd782222659d79fe579d04c664738c0c;p=thirdparty%2FChart.js.git inGroupRange function for bar charts label mode --- diff --git a/src/Chart.Bar.js b/src/Chart.Bar.js index fcf159978..4fea73f5c 100644 --- a/src/Chart.Bar.js +++ b/src/Chart.Bar.js @@ -208,6 +208,8 @@ } + this.tooltip.pivot(); + // Hover animations if(!this.animating){ var changed; @@ -223,7 +225,6 @@ (this.lastActive.length && !this.active.length)|| (this.lastActive.length && this.active.length && changed)){ - this.tooltip.pivot(); this.stop(); this.render(this.options.hoverAnimationDuration); } @@ -254,7 +255,7 @@ this.scale.update(); - this.eachElement(function(bar, index, datasetIndex){ + 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), diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 93b7deb5e..0fa13465d 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1371,14 +1371,18 @@ var vm = this._vm; return vm.base - vm.y; }, - inRange : function(chartX,chartY){ + inRange : function(mouseX,mouseY){ 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); + return (mouseX >= vm.x - vm.width/2 && mouseX <= vm.x + vm.width/2) && (mouseY >= vm.y && mouseY <= vm.base); } else{ - return (chartX >= vm.x - vm.width / 2 && chartX <= vm.x + vm.width / 2) && (chartY >= vm.base && chartY <= vm.y); + 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){