Skip to content

Commit

Permalink
If parent layer has an id, use the same id as a base for the Canvas e…
Browse files Browse the repository at this point in the history
…lements.
  • Loading branch information
elventear committed Oct 20, 2010
1 parent 5f04621 commit 95f17ae
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions jquery.flot.js
Expand Up @@ -136,7 +136,7 @@
ctx = null, octx = null, ctx = null, octx = null,
xaxes = [], yaxes = [], xaxes = [], yaxes = [],
plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
canvasWidth = 0, canvasHeight = 0, canvasWidth = 0, canvasHeight = 0, id,
plotWidth = 0, plotHeight = 0, plotWidth = 0, plotHeight = 0,
hooks = { hooks = {
processOptions: [], processOptions: [],
Expand Down Expand Up @@ -697,17 +697,22 @@
} }


function constructCanvas() { function constructCanvas() {
function makeCanvas(width, height) { function makeCanvas(width, height, id) {
var c = document.createElement('canvas'); var c = document.createElement('canvas');
c.width = width; c.width = width;
c.height = height; c.height = height;
if (id) c.id = id;
if (!c.getContext) // excanvas hack if (!c.getContext) // excanvas hack
c = window.G_vmlCanvasManager.initElement(c); c = window.G_vmlCanvasManager.initElement(c);
return c; return c;
} }


var new_id;

canvasWidth = placeholder.width(); canvasWidth = placeholder.width();
canvasHeight = placeholder.height(); canvasHeight = placeholder.height();
id = placeholder[0].id;

placeholder.html(""); // clear placeholder placeholder.html(""); // clear placeholder
if (placeholder.css("position") == 'static') if (placeholder.css("position") == 'static')
placeholder.css("position", "relative"); // for positioning labels and overlay placeholder.css("position", "relative"); // for positioning labels and overlay
Expand All @@ -719,11 +724,13 @@
window.G_vmlCanvasManager.init_(document); // make sure everything is setup window.G_vmlCanvasManager.init_(document); // make sure everything is setup


// the canvas // the canvas
canvas = $(makeCanvas(canvasWidth, canvasHeight)).appendTo(placeholder).get(0); new_id = id? id+'-1' : null;
canvas = $(makeCanvas(canvasWidth, canvasHeight, new_id)).appendTo(placeholder).get(0);
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");


// overlay canvas for interactive features // overlay canvas for interactive features
overlay = $(makeCanvas(canvasWidth, canvasHeight)).css({ position: 'absolute', left: 0, top: 0 }).appendTo(placeholder).get(0); new_id = id? id+'-2' : null;
overlay = $(makeCanvas(canvasWidth, canvasHeight, new_id)).css({ position: 'absolute', left: 0, top: 0 }).appendTo(placeholder).get(0);
octx = overlay.getContext("2d"); octx = overlay.getContext("2d");
octx.stroke(); octx.stroke();
} }
Expand Down

0 comments on commit 95f17ae

Please sign in to comment.