From 98b6361aa9dd3ead1f032f01ea6bfe6d75631bf2 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Wed, 30 Jan 2013 21:47:05 -0500 Subject: [PATCH] Preserve canvas elements on re-plot. Since the Canvas .text object is jQuery-wrapped, it was not preserved as expected when clearing the canvas of junk. I've replaced the selection with one based on element classes. --- jquery.flot.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 3e94cfe..5562bd7 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -189,13 +189,15 @@ Licensed under the MIT license. // Add the HTML text layer, if it doesn't already exist if (!this.text) { - this.text = $("
").css({ - position: "absolute", - top: 0, - left: 0, - bottom: 0, - right: 0 - }).insertAfter(this.element); + this.text = $("
") + .addClass("flot-text") + .css({ + position: "absolute", + top: 0, + left: 0, + bottom: 0, + right: 0 + }).insertAfter(this.element); } this.text.append(this._textBuffer); @@ -1122,7 +1124,7 @@ Licensed under the MIT license. // then whack any remaining obvious garbage left eventHolder.unbind(); - placeholder.children().not([surface.element, surface.text, overlay.element, overlay.text]).remove(); + placeholder.children(":not(.flot-base,.flot-overlay,.flot-text)").remove(); } // save in case we get replotted