diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-01-03 18:52:46 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2017-01-03 18:52:46 +0300 |
commit | 09a4655023c1e0d959577a635bfef2d01c6462e8 (patch) | |
tree | 63b4087ca719b7d356184bd2ceef93297e05aef1 /interface/js | |
parent | 16c8c89c354a62aae901c63a43688a164b4d9ea0 (diff) | |
download | rspamd-09a4655023c1e0d959577a635bfef2d01c6462e8.tar.gz rspamd-09a4655023c1e0d959577a635bfef2d01c6462e8.zip |
[WebUI] Turn d3pie's stuff into a reusable function,
do not destroy pie on data update
Diffstat (limited to 'interface/js')
-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() { |