From: Jan Nicklas Date: Fri, 10 Jul 2015 09:47:48 +0000 (+0200) Subject: More robust in-between arc calculation see #1301 X-Git-Tag: v1.1.0~25^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=961fd11098b84d0ffd0d319faf3483adb2e1d579;p=thirdparty%2FChart.js.git More robust in-between arc calculation see #1301 --- diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 44db42dfc..8d610418b 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1281,9 +1281,18 @@ y: chartY }); + // Normalize all angles to 0 - 2*PI (0 - 360°) + var pointRelativeAngle = pointRelativePosition.angle % (Math.PI * 2), + var startAngle = (Math.PI * 2 + this.startAngle) % (Math.PI * 2), + var endAngle = (Math.PI * 2 + this.endAngle) % (Math.PI * 2) || 360; + + // Calculate wether the pointRelativeAngle is between the start and the end angle + var betweenAngles = (endAngle < startAngle) ? + pointRelativeAngle <= endAngle || pointRelativeAngle >= startAngle: + pointRelativeAngle >= startAngle && pointRelativeAngle <= endAngle; + //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 withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius); return (betweenAngles && withinRadius); //Ensure within the outside of the arc centre, but inside arc outer