diff options
-rw-r--r-- | interface/js/rspamd.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/interface/js/rspamd.js b/interface/js/rspamd.js index 6c0af1dc6..2199d13d2 100644 --- a/interface/js/rspamd.js +++ b/interface/js/rspamd.js @@ -459,10 +459,21 @@ xhr.setRequestHeader('Password', getPassword()); }, success: function (data) { - if (pie) { - pie.destroy(); - } - pie = new d3pie("chart", { + pie = drawPie(pie, "chart", data); + } + }); + } + + function drawPie(obj, id, data, conf) { + if (obj) { + obj.updateProp("data.content", + data.filter(function (elt) { + return elt.value > 0; + }) + ); + } else { + obj = new d3pie(id, + $.extend({}, { "header": { "title": { "text": "Rspamd filter stats", @@ -538,9 +549,9 @@ "percentage": 100 } } - }); - } - }); + }, conf)); + } + return obj; } function initGraph() { |