From 371cefadfe5c50610bc8abfb923757e39d66f3ff Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Mon, 10 Sep 2018 14:44:57 +0100 Subject: make fixed reports line on reports graph optional Collideoscope doesn't have fixed reports so only add a line for fixed reports if there is data. --- web/js/dashboard.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'web/js/dashboard.js') diff --git a/web/js/dashboard.js b/web/js/dashboard.js index 318e64c76..848fb0c2e 100644 --- a/web/js/dashboard.js +++ b/web/js/dashboard.js @@ -139,21 +139,26 @@ $(function(){ data0 = $allReports.data('values-reports'), data1 = $allReports.data('values-fixed'); - window.chartAllReports = new Chart($allReports, { - type: 'line', - data: { - labels: labels, - datasets: [{ - data: data0, - pointRadius: pointRadiusFinalDot(data0.length, 4), - pointBackgroundColor: colours[1], - borderColor: colours[1] - }, { + var data = [{ + data: data0, + pointRadius: pointRadiusFinalDot(data0.length, 4), + pointBackgroundColor: colours[1], + borderColor: colours[1] + }]; + if ( data1 ) { + data.push({ data: data1, pointRadius: pointRadiusFinalDot(data1.length, 4), pointBackgroundColor: colours[3], borderColor: colours[3] - }] + }); + } + + window.chartAllReports = new Chart($allReports, { + type: 'line', + data: { + labels: labels, + datasets: data }, options: { animation: { -- cgit v1.2.3