+}
+
+$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
+ processLogEventForGraph(event, eventData);
+ if (!window.jobGraphShown) {
+ // Draw immediately, instead of waiting for the 5-second
+ // timer.
+ redrawIfNeeded.call(window, this);
+ }
+});
+
+function redrawIfNeeded(graph_div) {
+ if (!window.redraw) {
+ return;
+ }
+ window.redraw = false;
+
+ if (window.recreate) {
+ // Series have changed: we need to draw an entirely new graph.
+ // Running createJobGraph in a show() callback ensures the div
+ // is fully shown when morris uses it to size its svg element.
+ $(graph_div).show(0, createJobGraph.bind(window, $(graph_div).attr('id')));
+ window.jobGraphShown = true;
+ window.recreate = false;
+ } else {
+ window.jobGraph.setData(window.jobGraphData);
+ }
+}