]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Tooltip Position, Active Element Position, Tooltip animation follow
authorTanner Linsley <tannerlinsley@gmail.com>
Sat, 16 May 2015 05:07:21 +0000 (23:07 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Sat, 16 May 2015 05:07:21 +0000 (23:07 -0600)
src/Chart.Core.js

index fbb6f5397583811b6b42e0a001b42f3f0b53013e..939fecf2910bcfea210ee2549db54ee1eadcfa58 100755 (executable)
             Chart.animationService.cancelAnimation(this);
             return this;
         },
-        resize: function(callback) {
+        resize: function() {
             this.stop();
             var canvas = this.chart.canvas,
                 newWidth = getMaximumWidth(this.chart.canvas),
 
             retinaScale(this.chart);
 
-            if (typeof callback === "function") {
-                callback.apply(this, Array.prototype.slice.call(arguments, 1));
-            }
             return this;
         },
         redraw: noop,
     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() {
                     // 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);