Permalink
Browse files

Set processed back to false after processing.

This temporary fix addresses the problem described in #810, and possibly
#945, where calls to setData for a pie chart do nothing.
  • Loading branch information...
1 parent 7317b9c commit ef73cf7ec18c8964e0a3648719e5db6d919ae77f @dnschnur dnschnur committed Feb 3, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 jquery.flot.pie.js
View
23 jquery.flot.pie.js
@@ -270,6 +270,29 @@ More detail and specific examples can be found in the included HTML file.
ctx = newCtx;
+ // WARNING: HACK! REWRITE THIS CODE AS SOON AS POSSIBLE!
+
+ // When combining smaller slices into an 'other' slice, we need to
+ // add a new series. Since Flot gives plugins no way to modify the
+ // list of series, the pie plugin uses a hack where the first call
+ // to processDatapoints results in a call to setData with the new
+ // list of series, then subsequent processDatapoints do nothing.
+
+ // The plugin-global 'processed' flag is used to control this hack;
+ // it starts out false, and is set to true after the first call to
+ // processDatapoints.
+
+ // Unfortunately this turns future setData calls into no-ops; they
+ // call processDatapoints, the flag is true, and nothing happens.
+
+ // To fix this we'll set the flag back to false here in draw, when
+ // all series have been processed, so the next sequence of calls to
+ // processDatapoints once again starts out with a slice-combine.
+ // This is really a hack; in 0.9 we need to give plugins a proper
+ // way to modify series before any processing begins.
+
+ processed = false;
+
// calculate maximum radius and center point
maxRadius = Math.min(canvasWidth, canvasHeight / options.series.pie.tilt) / 2;

0 comments on commit ef73cf7

Please sign in to comment.