From fac37e3a53b467111bce250a74978d71ff8060f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 27 Feb 2018 12:02:25 +0100 Subject: [PATCH] Fix error with empty chart views When aggregating over only few data points, the weekly-aggregated views might end up empty. This led to an error, because the chart generation relied on the data not to be empty. This adds a corresponding check, which prevents the error and shows an empty chart as expected. Instead of showing users empty charts, views with no data should be hidden from the users. This will be addressed separately. --- docs/assets/js/charts.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/assets/js/charts.js b/docs/assets/js/charts.js index 825df55f..96123199 100644 --- a/docs/assets/js/charts.js +++ b/docs/assets/js/charts.js @@ -256,6 +256,9 @@ function aggregateTimeData(data, aggregationConfig) function buildHistoryChartData(view) { + if (view.data.length == 0) + return Array(); + const originalDataSeries = Object.keys(view.data[0]).slice(1); const dataSeries = 'series' in view ? view.series : originalDataSeries; const visibleDataSeries = 'visibleSeries' in view ? view.visibleSeries : originalDataSeries;