Skip to content

Commit

Permalink
lib: Retry maybe_start until we have a positive width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
petervo committed Oct 5, 2017
1 parent 4f82133 commit 135ba5f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/lib/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ function setup_plot(graph_id, grid, data, user_options) {

var outer_div = $(graph_id);
var inner_div = $('<div/>');
var starting = null;
outer_div.empty();
outer_div.append(inner_div);

Expand Down Expand Up @@ -1043,13 +1044,19 @@ function setup_plot(graph_id, grid, data, user_options) {
}

function maybe_start() {
if (running && outer_div.width() !== 0 && outer_div.height() !== 0) {
if (running && outer_div.width() > 0 && outer_div.height() > 0) {
if (!plot) {
sync_divs ();
plot = $.plot(inner_div, data, options);
} else
resize();

if (starting)
window.clearInterval(starting);
} else if (!starting) {
starting = window.setInterval(maybe_start, 500);
}

}

function stop ()
Expand Down

0 comments on commit 135ba5f

Please sign in to comment.