From 961fd11098b84d0ffd0d319faf3483adb2e1d579 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Fri, 10 Jul 2015 11:47:48 +0200 Subject: [PATCH] More robust in-between arc calculation see #1301 --- src/Chart.Core.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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