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

Added processOffset and drawBackground hooks

parent 1a99246c
...@@ -919,8 +919,8 @@ can call: ...@@ -919,8 +919,8 @@ can call:
- pointOffset({ x: xpos, y: ypos }) - pointOffset({ x: xpos, y: ypos })
Returns the calculated offset of the data point at (x, y) in data 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 space within the placeholder div. If you are working with multiple
can specify the x and y axis references, e.g. axes, you can specify the x and y axis references, e.g.
o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 }) o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 })
// o.left and o.top now contains the offset within the div // o.left and o.top now contains the offset within the div
...@@ -1114,6 +1114,25 @@ hooks in the plugins bundled with Flot. ...@@ -1114,6 +1114,25 @@ hooks in the plugins bundled with Flot.
doesn't check it or do any normalization on it afterwards. 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] - drawSeries [phase 5]
function(plot, canvascontext, series) function(plot, canvascontext, series)
......
...@@ -152,6 +152,8 @@ ...@@ -152,6 +152,8 @@
processOptions: [], processOptions: [],
processRawData: [], processRawData: [],
processDatapoints: [], processDatapoints: [],
processOffset: [],
drawBackground: [],
drawSeries: [], drawSeries: [],
draw: [], draw: [],
bindEvents: [], bindEvents: [],
...@@ -1025,6 +1027,8 @@ ...@@ -1025,6 +1027,8 @@
for (var a in plotOffset) for (var a in plotOffset)
plotOffset[a] = showGrid ? options.grid.borderWidth : 0; plotOffset[a] = showGrid ? options.grid.borderWidth : 0;
executeHooks(hooks.processOffset, [plotOffset]);
// init axes // init axes
$.each(axes, function (_, axis) { $.each(axes, function (_, axis) {
axis.show = axis.options.show; axis.show = axis.options.show;
...@@ -1441,6 +1445,8 @@ ...@@ -1441,6 +1445,8 @@
function draw() { function draw() {
ctx.clearRect(0, 0, canvasWidth, canvasHeight); ctx.clearRect(0, 0, canvasWidth, canvasHeight);
executeHooks(hooks.drawBackground, [ctx]);
var grid = options.grid; var grid = options.grid;
// draw background, if any // 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