From 1f122518dde1e7d67fa916e9a5a1cbee59667537 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Fri, 24 Aug 2018 13:32:07 +0300 Subject: [PATCH] resolves #64: graph jumps to previous values Ensure the old chart is completely removed before loading a new set of values due to different page or sort options --- src/resources/js/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/resources/js/app.js b/src/resources/js/app.js index a8a907e..b4bc696 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -403,6 +403,7 @@ var Job = function() { pages: 0, sort: {} }; + var chtBt = null; return Vue.extend({ template: '#job', mixins: [WebsocketHandler, Utils, ProgressUpdater], @@ -419,7 +420,11 @@ var Job = function() { state.pages = msg.pages; state.sort = msg.sort; - var chtBt = new Chart(document.getElementById("chartBt"), { + // "status" comes again if we change page/sorting. Delete the + // old chart and recreate it to prevent flickering of old data + if(chtBt) + chtBt.destroy(); + chtBt = new Chart(document.getElementById("chartBt"), { type: 'bar', data: { labels: msg.recent.map(function(e) { @@ -443,7 +448,6 @@ var Job = function() { } } chtBt.update(); - }, job_queued: function() { state.nQueued++;