summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-03 16:06:22 +0000
committerGitHub <noreply@github.com>2017-01-03 16:06:22 +0000
commit96d30cb85c4cf8fb59812e73263ae725ba05030c (patch)
treecb67d385a292d9699137d4db25726308553cff15
parent9ac7c450c77d4b0722e0080292f20e7680b4e351 (diff)
parent09a4655023c1e0d959577a635bfef2d01c6462e8 (diff)
downloadrspamd-96d30cb85c4cf8fb59812e73263ae725ba05030c.tar.gz
rspamd-96d30cb85c4cf8fb59812e73263ae725ba05030c.zip
Merge pull request #1298 from moisseev/totals
[WebUI] Turn d3pie's stuff into a reusable function,
-rw-r--r--interface/js/rspamd.js25
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() {