diff options
author | Joris | 2022-09-04 11:29:41 +0200 |
---|---|---|
committer | Joris | 2022-09-04 11:29:54 +0200 |
commit | 29e9883b2045f176dff533850e5fe861ac74db1d (patch) | |
tree | bcd69761c0c945530d7cd18d4264ed185ab5056a /assets/main.js | |
parent | 26237238cd8f2daf501af89b3b1427eccc193375 (diff) | |
download | budget-29e9883b2045f176dff533850e5fe861ac74db1d.tar.gz budget-29e9883b2045f176dff533850e5fe861ac74db1d.tar.bz2 budget-29e9883b2045f176dff533850e5fe861ac74db1d.zip |
Use chart.js version 3
No more CSS injection compared to version 2.
Diffstat (limited to 'assets/main.js')
-rw-r--r-- | assets/main.js | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/assets/main.js b/assets/main.js index 4662482..bc5d65c 100644 --- a/assets/main.js +++ b/assets/main.js @@ -209,44 +209,34 @@ function show_statistics() { }, options: { - responsive: true, - tooltips: { - mode: 'nearest', + interaction: { intersect: false, - callbacks: { - title: (tooltipItem, data) => { - return capitalize(prettyPrintMonth(tooltipItem[0].xLabel)) - }, - label: (tooltipItem, data) => { - let label = data.datasets[tooltipItem.datasetIndex].label || '' - if (label) { - label += ': ' - } - label += `${tooltipItem.yLabel} €` - return label - } - } - }, - hover: { - mode: 'nearest', - intersect: true }, scales: { - xAxes: [ - { - ticks: { - callback: prettyPrintMonth - } + x: { + ticks: { + callback: index => prettyPrintMonth(dates[index]) } - ], - yAxes: [ - { - ticks: { - beginAtZero: true, - callback: value => `${value} €` + }, + y: { + ticks: { + beginAtZero: true, + callback: value => `${value.toLocaleString('fr-FR')} €` + } + } + }, + plugins: { + tooltip: { + callbacks: { + title: items => capitalize(prettyPrintMonth(items[0].label)), + label: item => { + let label = item.dataset.label || '' + if (label) label += ': ' + label += `${item.raw.toLocaleString('fr-FR')} €` + return label } } - ] + } } } }) |