flot/flot — pull request #879 by dnschnur (2012-11-25 04:43:12+00:00)
Title: Fixed pie plugin 100% slice issues on IE7/8.

This pull request fixes the long-standing problem with pie charts becoming invisible when they have one slice that equals or approaches 100% of the pie. This happened mainly when using excanvas under IE7/8, but was in at least one instance reported to occur in native canvas on Android as well.

This closes #444, #658, #726, #824, and #850.

The problem occurs when the canvas or VML (which underlies excanvas) engine's arc function is given a start and end angle that are equal. Rather than drawing a circle, engines that exhibit the problem don't draw anything at all, either as an optimization or oversight.

Since floating-point representation is inexact, the problem happens whenever the difference between the two angles is small enough for the browser to consider them equal. It can therefore happen even when one slice isn't a full 100%, as long as it comes close, and can come and go based on the exact slice values and the size of the plot.

Flot isn't the first to encounter this problem, and other solutions have involved adding or subtracting small values from the angle in an attempt to make the two values unequal. This is unreliable, can result in very tiny slices appearing larger than they should, and is really kind of a hack. This pull request instead draws every arc in two parts, each covering half the slice's angle. This guarantees that the start and end angle of a visible slice are never equal.

I've also done a bunch of code-style cleanup, since style varied greatly across the plugin.