Skip to content

Commit

Permalink
Moved other hooks out of the processOptions hook.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dnschnur committed Feb 3, 2013
1 parent f294bf1 commit a03c4c1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions jquery.flot.pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit a03c4c1

Please sign in to comment.