You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/* Flot plugin for automatically redrawing plots as the placeholder resizes.
|
|
|
|
Copyright (c) 2007-2013 IOLA and Ole Laursen.
|
|
Licensed under the MIT license.
|
|
|
|
It works by listening for changes on the placeholder div (through the jQuery
|
|
resize event plugin) - if the size changes, it will redraw the plot.
|
|
|
|
There are no options. If you need to disable the plugin for some plots, you
|
|
can just fix the size of their placeholders.
|
|
|
|
*/
|
|
|
|
(function ($) {
|
|
var options = { }; // no options
|
|
|
|
function init(plot) {
|
|
function onResize() {
|
|
var placeholder = plot.getPlaceholder();
|
|
|
|
// somebody might have hidden us and we can't plot
|
|
// when we don't have the dimensions
|
|
if (placeholder.width() === 0 || placeholder.height() === 0) {
|
|
return;
|
|
}
|
|
|
|
plot.resize();
|
|
plot.setupGrid();
|
|
plot.draw();
|
|
}
|
|
|
|
function bindEvents(plot) {
|
|
plot.getPlaceholder().resize(onResize);
|
|
}
|
|
|
|
function shutdown(plot) {
|
|
plot.getPlaceholder().unbind("resize", onResize);
|
|
}
|
|
|
|
plot.hooks.bindEvents.push(bindEvents);
|
|
plot.hooks.shutdown.push(shutdown);
|
|
}
|
|
|
|
$.plot.plugins.push({
|
|
init: init,
|
|
options: options,
|
|
name: "resize",
|
|
version: "1.0"
|
|
});
|
|
})(jQuery);
|