From e0c99fa80c7d23c99e8197d60efdad9e6c500122 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Feb 2020 13:15:48 +0100 Subject: [PATCH] Fix #3145 --- public/v1/js/ff/charts.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/v1/js/ff/charts.js b/public/v1/js/ff/charts.js index 4dbfa70e54..e704c87bca 100644 --- a/public/v1/js/ff/charts.js +++ b/public/v1/js/ff/charts.js @@ -374,9 +374,16 @@ function drawAChart(URI, container, chartType, options, colorData) { $.getJSON(URI).done(function (data) { containerObj.removeClass('general-chart-error'); - console.log(data); - if (!(Array.isArray(data) && data.length) || - (typeof data.labels != 'undefined' && data.labels.length === 0)) { + + // if result is empty array, or the labels array is empty, show error. + if ( + // is undefined + typeof data === 'undefined' || + // is empty + 0 === data.length || + // isn't empty but contains no labels + (data.length > 0 && typeof data.labels !== 'undefined' && 0 === data.labels.length) + ) { // remove the chart container + parent var holder = $('#' + container).parent().parent(); if (holder.hasClass('box') || holder.hasClass('box-body')) {