// 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' }) + '
' + 'Sum of Accounts: ' + params[0].data[1] + '
' + 'Sum of Savings: ' + params[1].data[1] + ' €' }; 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();