From 7ee31a609911981ae12a17fe55235d8613ce0b98 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sat, 24 Nov 2012 22:52:18 -0500 Subject: [PATCH] Added work-around for the Excanvas 100% arc bug. When a slice equals (or comes close enough that it is equal in floating-point representation) 100% of the pie, it was no longer drawn by Excanvas. This is because of a long-standing issue where VML won't draw an arc whose begin and end are the same. Rather than some hack, like adding/subtracting a small value, we'll simply draw two arcs for every slice, with each covering half of the slice's angle. --- jquery.flot.pie.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index 8efc539..30e22fd 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -436,7 +436,8 @@ More detail and specific examples can be found in the included HTML file. } //ctx.arc(0, 0, radius, 0, angle, false); // This doesn't work properly in Opera - ctx.arc(0, 0, radius,currentAngle, currentAngle + angle, false); + ctx.arc(0, 0, radius,currentAngle, currentAngle + angle / 2, false); + ctx.arc(0, 0, radius,currentAngle + angle / 2, currentAngle + angle, false); ctx.closePath(); //ctx.rotate(angle); // This doesn't work properly in Opera currentAngle += angle; @@ -576,7 +577,8 @@ More detail and specific examples can be found in the included HTML file. ctx.beginPath(); ctx.moveTo(0, 0); // Center of the pie //ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here. - ctx.arc(0, 0, radius, s.startAngle, s.startAngle + s.angle, false); + ctx.arc(0, 0, radius, s.startAngle, s.startAngle + s.angle / 2, false); + ctx.arc(0, 0, radius, s.startAngle + s.angle / 2, s.startAngle + s.angle, false); ctx.closePath(); x = mouseX - centerLeft; y = mouseY - centerTop; @@ -741,7 +743,8 @@ More detail and specific examples can be found in the included HTML file. if (Math.abs(series.angle - Math.PI * 2) > 0.000000001) { octx.moveTo(0, 0); // Center of the pie } - octx.arc(0, 0, radius, series.startAngle, series.startAngle + series.angle, false); + octx.arc(0, 0, radius, series.startAngle, series.startAngle + series.angle / 2, false); + octx.arc(0, 0, radius, series.startAngle + series.angle / 2, series.startAngle + series.angle, false); octx.closePath(); octx.fill(); }