diff options
Diffstat (limited to 'modules-available/statistics/clientscript.js')
-rw-r--r-- | modules-available/statistics/clientscript.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/modules-available/statistics/clientscript.js b/modules-available/statistics/clientscript.js index 3c166f64..8ed2129c 100644 --- a/modules-available/statistics/clientscript.js +++ b/modules-available/statistics/clientscript.js @@ -73,4 +73,35 @@ function addFilter(field, op, argument) { function refresh() { $('#query-form').submit(); +} + +function makeUsagePie($parent) { + var data = $parent.data('chart'); + var chartData = { + datasets: [{ + data: data.map(function(x) { return x.value; }), + backgroundColor: data.map(function(x) { return x.color; }), + tooltip: data.map(function(x) { return x.tooltip; }), + }] + }; + var $canv = $('<canvas style="width:250px;height:250px" width="250" height="250">'); + $parent.append($canv); + (function() { + new Chart($canv[0].getContext('2d'), { + type: 'pie', data: chartData, options: { + animation: false, + plugins: { + tooltip: { + enabled: true, + callbacks: { + label: function(context) { + return context.dataset.tooltip[context.dataIndex]; + } + } + }, + legend: {display: false} + } + } + }); + })(); }
\ No newline at end of file |