Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only save references to old Canvas methods once.

Plugins are re-initialized with each re-plot (which may not be the right
thing to do, but that's how it works for now).  The previous approach of
saving references to the original Canvas functions therefore broke,
since the second time around we'd get a reference to our new function.
Instead we hold those references as globals within the plugin, and only
set them once.

This whole idea of replacing prototype functions is, now that I step
back and look at it, really awful.  This needs to be changed ASAP to
something less ridiculous.
  • Loading branch information...
commit c41b09b844232e4ec944773bc94156094e845974 1 parent 53ce9ad
@dnschnur dnschnur authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 jquery.flot.canvas.js
View
11 jquery.flot.canvas.js
@@ -33,16 +33,25 @@ browser, but needs to redraw with canvas text when exporting as an image.
canvas: true
};
+ var render, getTextInfo, addText;
+
// Cache the prototype hasOwnProperty for faster access
var hasOwnProperty = Object.prototype.hasOwnProperty;
function init(plot, classes) {
- var Canvas = classes.Canvas,
+ var Canvas = classes.Canvas;
+
+ // We only want to replace the functions once; the second time around
+ // we would just get our new function back. This whole replacing of
+ // prototype functions is a disaster, and needs to be changed ASAP.
+
+ if (render == null) {
getTextInfo = Canvas.prototype.getTextInfo,
addText = Canvas.prototype.addText,
render = Canvas.prototype.render;
+ }
// Finishes rendering the canvas, including overlaid text
Please sign in to comment.
Something went wrong with that request. Please try again.