diff options
author | Simon Rettberg | 2022-07-04 18:25:06 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-07-04 18:25:06 +0200 |
commit | 9ca5c9bca40fa7e962b932364228731a6b9714a8 (patch) | |
tree | aae9463091b88826b6a931013ae6eab1935d6df6 /modules-available/statistics/templates/filterbox.html | |
parent | [statistics] Add a few more RAM/HDD size groups, future is catching up.. (diff) | |
download | slx-admin-9ca5c9bca40fa7e962b932364228731a6b9714a8.tar.gz slx-admin-9ca5c9bca40fa7e962b932364228731a6b9714a8.tar.xz slx-admin-9ca5c9bca40fa7e962b932364228731a6b9714a8.zip |
[js_chart] Update to Chart.js 3.0.8
Diffstat (limited to 'modules-available/statistics/templates/filterbox.html')
-rw-r--r-- | modules-available/statistics/templates/filterbox.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 72754b21..aba4b41c 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -117,6 +117,48 @@ document.addEventListener("DOMContentLoaded", function () { }); }); + // All the pie chars + function makePieChart($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; }) + }] + }; + var $canv = $('<canvas style="width:100%;height:250px">'); + $parent.append($canv); + (function() { + var $dest = $parent.data('chart-dest'); + var cur = null; + new Chart($canv[0].getContext('2d'), { + type: 'pie', data: chartData, options: { + animation: false, + onHover: function (_, list) { + if (list.length === 0 || list[0].index !== cur) { + if (cur !== null) { + $($dest + cur).removeClass('slx-bold'); + cur = null; + } + } + if (list.length !== 0 && list[0].index !== cur) { + console.log(list[0]); + cur = list[0].index; + $($dest + cur).addClass('slx-bold'); + } + }, + plugins: { + tooltip: {enabled: false}, + legend: {display: false} + } + } + }); + })(); + } + $('.auto-chart').each(function() { + makePieChart($(this)); + }); + }, false); function popupFilter(field) { |