Commit 3ba7f28e authored by olau@iola.dk's avatar olau@iola.dk

Revamp resize plugin to reuse the plot object and disconnect its

resize event properly


git-svn-id: https://flot.googlecode.com/svn/trunk@318 1e0a6537-2640-0410-bfb7-f154510ff394
parent 4e027816
...@@ -81,6 +81,7 @@ Changes: ...@@ -81,6 +81,7 @@ Changes:
types (sponsored by Utility Data Corporation). types (sponsored by Utility Data Corporation).
- Resize plugin for automatically redrawing when the placeholder - Resize plugin for automatically redrawing when the placeholder
changes size, e.g. on window resizes (sponsored by Novus Partners). changes size, e.g. on window resizes (sponsored by Novus Partners).
A resize() method has been added to plot object facilitate this.
- Support Infinity/-Infinity for plotting asymptotes by hacking it - Support Infinity/-Infinity for plotting asymptotes by hacking it
into +/-Number.MAX_VALUE (reported by rabaea.mircea). into +/-Number.MAX_VALUE (reported by rabaea.mircea).
- Support for restricting navigate plugin to not pan/zoom an axis (based - Support for restricting navigate plugin to not pan/zoom an axis (based
......
...@@ -23,14 +23,9 @@ plots, you can just fix the size of their placeholders. ...@@ -23,14 +23,9 @@ plots, you can just fix the size of their placeholders.
(function ($) { (function ($) {
var redrawing = 0;
var options = { }; // no options var options = { }; // no options
function init(plot) { function init(plot) {
function bindEvents(plot, eventHolder) {
if (!redrawing)
plot.getPlaceholder().resize(onResize);
function onResize() { function onResize() {
var placeholder = plot.getPlaceholder(); var placeholder = plot.getPlaceholder();
...@@ -39,13 +34,21 @@ plots, you can just fix the size of their placeholders. ...@@ -39,13 +34,21 @@ plots, you can just fix the size of their placeholders.
if (placeholder.width() == 0 || placeholder.height() == 0) if (placeholder.width() == 0 || placeholder.height() == 0)
return; return;
++redrawing; plot.resize();
$.plot(placeholder, plot.getData(), plot.getOptions()); plot.setupGrid();
--redrawing; plot.draw();
}
function bindEvents(plot, eventHolder) {
plot.getPlaceholder().resize(onResize);
} }
function shutdown(plot, eventHolder) {
plot.getPlaceholder().unbind("resize", onResize);
} }
plot.hooks.bindEvents.push(bindEvents); plot.hooks.bindEvents.push(bindEvents);
plot.hooks.shutdown.push(shutdown);
} }
$.plot.plugins.push({ $.plot.plugins.push({
......
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