Skip to content

Firefly III: a personal finances manager

Fix #3145

James Colee0c99fa80c7d
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')) {