feat(dashboard): #82 add chart for sum of account and savings
Some checks failed
Build Docker Image / Build-Docker-Image (push) Has been cancelled

This commit is contained in:
2025-06-19 13:28:49 +02:00
parent 3b3343bdb5
commit c94a9447f2
13 changed files with 241 additions and 173 deletions

38
static/js/dashboard.js Normal file
View File

@@ -0,0 +1,38 @@
// Initialize the echarts instance based on the prepared dom
async function init() {
const element = document.getElementById('graph')
if (element === null) {
return;
}
var myChart = echarts.init(element);
try {
const response = await fetch("/dashboard/dataset");
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const option = await response.json();
option.tooltip.formatter = function (params) {
return new Date(params[0].data[0]).toLocaleString([], { day: 'numeric', month: 'short', year: 'numeric' }) +
'<br />' +
'Sum of Accounts: <span class="font-bold">' + params[0].data[1] + '</span> € <br />' +
'Sum of Savings: <span class="font-bold">' + params[1].data[1] + '</span> €'
};
const chart = myChart.setOption(option);
window.addEventListener('resize', function() {
myChart.resize();
});
console.log("initialized charts");
} catch (error) {
console.error(error.message);
}
// Display the chart using the configuration items and data just specified.
}
init();