diff options
author | Simon Rettberg | 2024-09-12 11:27:34 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-09-12 11:27:34 +0200 |
commit | 8c960784b8c3524a23a3c0a5a33926a3aa887b70 (patch) | |
tree | 7202d67efd1047c051821eab969c220c1083801b /modules-available/statistics/clientscript.js | |
parent | [rebootcontrol] Only run the Taskmanager check if we got work to do (diff) | |
download | slx-admin-8c960784b8c3524a23a3c0a5a33926a3aa887b70.tar.gz slx-admin-8c960784b8c3524a23a3c0a5a33926a3aa887b70.tar.xz slx-admin-8c960784b8c3524a23a3c0a5a33926a3aa887b70.zip |
[statistics] Extend usage history to 10 days, add pie chart
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 |