From aceb683d07310c695dd61a2e0a693d5f1c098bf9 Mon Sep 17 00:00:00 2001 From: Sander Dorigo Date: Tue, 14 Oct 2014 07:27:06 +0200 Subject: [PATCH] Remove chart when nothing to show. --- public/assets/javascript/firefly/index.js | 70 ++++++++++++----------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/public/assets/javascript/firefly/index.js b/public/assets/javascript/firefly/index.js index 0b8d96318a..b8d5efda98 100644 --- a/public/assets/javascript/firefly/index.js +++ b/public/assets/javascript/firefly/index.js @@ -212,41 +212,45 @@ $(function () { }); $.getJSON('chart/home/recurring').success(function (data) { - $('#recurring').highcharts({ - title: { - text: null - }, - credits: { - enabled: false - }, - tooltip: { - formatter: function () { - if (this.point.objType == 'paid') { - return this.key + ': \u20AC ' + Highcharts.numberFormat(this.y, 2); - } else { - return this.key + ': ~\u20AC ' + Highcharts.numberFormat(this.y, 2); - } - - } - }, - plotOptions: { - pie: { - events: { - click: function (e) { - if (e.point.url != null) { - window.location = e.point.url; - } + if (data[0].data.length == 0) { + $('#recurring').parent().parent().remove(); + } else { + $('#recurring').highcharts({ + title: { + text: null + }, + credits: { + enabled: false + }, + tooltip: { + formatter: function () { + if (this.point.objType == 'paid') { + return this.key + ': \u20AC ' + Highcharts.numberFormat(this.y, 2); + } else { + return this.key + ': ~\u20AC ' + Highcharts.numberFormat(this.y, 2); } - }, - allowPointSelect: true, - cursor: 'pointer', - dataLabels: { - enabled: false + } - } - }, - series: data - }); + }, + plotOptions: { + pie: { + events: { + click: function (e) { + if (e.point.url != null) { + window.location = e.point.url; + } + } + }, + allowPointSelect: true, + cursor: 'pointer', + dataLabels: { + enabled: false + } + } + }, + series: data + }); + } }); }); \ No newline at end of file