More robust in-between arc calculation see #1301

This commit is contained in:
Jan Nicklas 2015-07-10 11:47:48 +02:00
parent 66cf8ab787
commit 961fd11098

View File

@ -1281,9 +1281,18 @@
y: chartY 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 //Check if within the range of the open/close angle
var betweenAngles = (pointRelativePosition.angle >= this.startAngle && pointRelativePosition.angle <= this.endAngle), var withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius);
withinRadius = (pointRelativePosition.distance >= this.innerRadius && pointRelativePosition.distance <= this.outerRadius);
return (betweenAngles && withinRadius); return (betweenAngles && withinRadius);
//Ensure within the outside of the arc centre, but inside arc outer //Ensure within the outside of the arc centre, but inside arc outer