]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Make the angle calculations more robust. Also ensure that angles in polar area charts... 1173/head
authorEvert Timberg <evert.timberg@gmail.com>
Sat, 6 Jun 2015 15:06:40 +0000 (11:06 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Sat, 6 Jun 2015 15:06:40 +0000 (11:06 -0400)
src/Chart.Core.js
src/Chart.PolarArea.js

index 9afe5f5bbc5bc3078e3cbec7f8299764197fd9ae..861188c0c78cc2598432404571a25be4f6c4cd85 100755 (executable)
             });
 
             // 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),
index f0ceff750ccafe7c8758e4f75dea4acc55617e57..b7e52682fd6d313540aa235cc371c821c96d25c2 100644 (file)
 
                 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: {
                         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),
 
                 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, {