From cb53be42530d020fdbcad1d6e4eef0643ed874c9 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 10 Nov 2017 09:22:46 +0100 Subject: [PATCH] Prevent double display of org in line chart --- static/js/contrib.js | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/static/js/contrib.js b/static/js/contrib.js index 4a7a8e6..3de70dd 100644 --- a/static/js/contrib.js +++ b/static/js/contrib.js @@ -446,21 +446,31 @@ function updateProgressHeader(org) { //update overtake points updateOvertakePnts(); - //Add new data to linechart - $.getJSON( url_getOrgOvertime+'?org='+org, function( data ) { - var toPlot = dataTop5Overtime.slice(0); //cloning data - // transform secs into date - var new_data = []; - for(list of data['data']) { - new_data.push([new Date(list[0]*1000), list[1]]); - } - data['data'] = new_data; - toPlot.push(data); - plotLineChart.setData(toPlot); - plotLineChart.setupGrid(); - plotLineChart.draw(); - }); + //Add new data to linechart + var flag_already_displayed = false; + for(obj of dataTop5Overtime) { //check if already displayed + if (obj.label == currOrg) { + flag_already_displayed = true; + break; + } + } + if (!flag_already_displayed) { + $.getJSON( url_getOrgOvertime+'?org='+org, function( data ) { + var toPlot = dataTop5Overtime.slice(0); //cloning data + // transform secs into date + var new_data = []; + for(list of data['data']) { + new_data.push([new Date(list[0]*1000), list[1]]); + } + data['data'] = new_data; + toPlot.push(data); + + plotLineChart.setData(toPlot); + plotLineChart.setupGrid(); + plotLineChart.draw(); + }); + } } function showOnlyOrg() {