From ef73cf7ec18c8964e0a3648719e5db6d919ae77f Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 3 Feb 2013 14:32:13 -0500 Subject: [PATCH] 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. --- jquery.flot.pie.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index 8c19e4f..da2ab7f 100644 --- a/jquery.flot.pie.js +++ b/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;