Commit 4ee1e04e authored by David Schnur's avatar David Schnur

Added processOffset and drawBackground hooks

parent 1a99246c
......@@ -919,8 +919,8 @@ can call:
- pointOffset({ x: xpos, y: ypos })
Returns the calculated offset of the data point at (x, y) in data
space within the placeholder div. If you are working with multiple axes, you
can specify the x and y axis references, e.g.
space within the placeholder div. If you are working with multiple
axes, you can specify the x and y axis references, e.g.
o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 })
// o.left and o.top now contains the offset within the div
......@@ -1114,6 +1114,25 @@ hooks in the plugins bundled with Flot.
doesn't check it or do any normalization on it afterwards.
- processOffset [phase 4]
function(plot, offset)
Called after Flot has initialized the plot's offset, but before it
draws any axes or plot elements. This hook is useful for customizing
the margins between the grid and the edge of the canvas. "offset" is
an object with attributes "top", "bottom", "left" and "right",
corresponding to the margins on the four sides of the plot.
- drawBackground [phase 5]
function(plot, canvascontext)
Called before all other drawing operations. Used to draw backgrounds
or other custom elements before the plot or axes have been draw.
- drawSeries [phase 5]
function(plot, canvascontext, series)
......
......@@ -152,6 +152,8 @@
processOptions: [],
processRawData: [],
processDatapoints: [],
processOffset: [],
drawBackground: [],
drawSeries: [],
draw: [],
bindEvents: [],
......@@ -1025,6 +1027,8 @@
for (var a in plotOffset)
plotOffset[a] = showGrid ? options.grid.borderWidth : 0;
executeHooks(hooks.processOffset, [plotOffset]);
// init axes
$.each(axes, function (_, axis) {
axis.show = axis.options.show;
......@@ -1441,6 +1445,8 @@
function draw() {
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
executeHooks(hooks.drawBackground, [ctx]);
var grid = options.grid;
// draw background, if any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment