From a03c4c199de09744053a0780d34a12af14c5bf19 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 3 Feb 2013 11:54:20 -0500 Subject: [PATCH] Moved other hooks out of the processOptions hook. In plugins we should never add hooks conditionally; the condition should remain within individual hooks, so the plugin can be toggled at any time. Ideally we should also 'inline' the hook functions, since they're used nowhere else. But since that would involve a lot of code changes, we'll put it off until the broader cleanup effort scheduled for 0.9.0. --- jquery.flot.pie.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index 59787513..cea94292 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -113,20 +113,9 @@ More detail and specific examples can be found in the included HTML file. } else if (options.series.pie.tilt < 0) { options.series.pie.tilt = 0; } - - // add processData hook to do transformations on the data - - plot.hooks.processDatapoints.push(processDatapoints); - plot.hooks.drawOverlay.push(drawOverlay); - - // draw hook - - plot.hooks.draw.push(draw); } }); - // bind hoverable events - plot.hooks.bindEvents.push(function(plot, eventHolder) { var options = plot.getOptions(); if (options.series.pie.show) { @@ -139,6 +128,27 @@ More detail and specific examples can be found in the included HTML file. } }); + plot.hooks.processDatapoints.push(function(plot, series, data, datapoints) { + var options = plot.getOptions(); + if (options.series.pie.show) { + processDatapoints(plot, series, data, datapoints); + } + }); + + plot.hooks.drawOverlay.push(function(plot, octx) { + var options = plot.getOptions(); + if (options.series.pie.show) { + drawOverlay(plot, octx); + } + }); + + plot.hooks.draw.push(function(plot, newCtx) { + var options = plot.getOptions(); + if (options.series.pie.show) { + draw(plot, newCtx); + } + }); + // debugging function that prints out an object function alertObject(obj) {