diff --git a/example/dashboards.yaml b/example/dashboards.yaml index ea16240..bc084a6 100644 --- a/example/dashboards.yaml +++ b/example/dashboards.yaml @@ -770,7 +770,7 @@ dashboards: onClick: (event) => { const link = panel.queries[0].link .replaceAll("#", "%23") - .replace("{account}", event.name) + .replace("{account}", accounts[event.dataIndex]) .replace("{time}", event.seriesName); window.open(link); }, diff --git a/frontend/tests/e2e/__snapshots__/dashboards.test.js.snap b/frontend/tests/e2e/__snapshots__/dashboards.test.js.snap index a30390a..88a351d 100644 --- a/frontend/tests/e2e/__snapshots__/dashboards.test.js.snap +++ b/frontend/tests/e2e/__snapshots__/dashboards.test.js.snap @@ -4111,7 +4111,7 @@ exports[`Dashboard: HTML Snapshot Tests Income and Expenses 1`] = ` ] } ], - "script": "const currencyFormat = new Intl.NumberFormat(undefined, {\\n style: \\"currency\\",\\n currency: ledger.ccy,\\n maximumFractionDigits: 0,\\n});\\nconst years = helpers.iterateYears(ledger.dateFirst, ledger.dateLast);\\nconst maxExpenseAccounts = 10; // number of expense accounts to show (sorted by biggest expenses)\\n\\nconst accountSums = {};\\nconst amounts = {};\\nfor (let row of panel.queries[0].result) {\\n if (!(row.account in accountSums)) accountSums[row.account] = 0;\\n amounts[\`\${row.year}/\${row.account}\`] = row.value[ledger.ccy];\\n accountSums[row.account] += row.value[ledger.ccy];\\n}\\n\\nconst accounts = Object.entries(accountSums)\\n .sort(([, a], [, b]) =\\u003e b - a)\\n .map(([name]) =\\u003e name)\\n .slice(0, maxExpenseAccounts)\\n .reverse();\\nreturn {\\n legend: {\\n top: \\"bottom\\",\\n },\\n xAxis: {\\n axisLabel: {\\n formatter: currencyFormat.format,\\n },\\n },\\n yAxis: {\\n data: accounts.map((account) =\\u003e account.split(\\":\\").pop()),\\n },\\n series: years.map((year) =\\u003e ({\\n type: \\"bar\\",\\n name: year,\\n data: accounts.map((account) =\\u003e amounts[\`\${year}/\${account}\`] ?? 0),\\n label: {\\n show: true,\\n position: \\"right\\",\\n formatter: (params) =\\u003e currencyFormat.format(params.value),\\n },\\n })),\\n onClick: (event) =\\u003e {\\n const link = panel.queries[0].link\\n .replaceAll(\\"#\\", \\"%23\\")\\n .replace(\\"{account}\\", event.name)\\n .replace(\\"{time}\\", event.seriesName);\\n window.open(link);\\n },\\n};\\n", + "script": "const currencyFormat = new Intl.NumberFormat(undefined, {\\n style: \\"currency\\",\\n currency: ledger.ccy,\\n maximumFractionDigits: 0,\\n});\\nconst years = helpers.iterateYears(ledger.dateFirst, ledger.dateLast);\\nconst maxExpenseAccounts = 10; // number of expense accounts to show (sorted by biggest expenses)\\n\\nconst accountSums = {};\\nconst amounts = {};\\nfor (let row of panel.queries[0].result) {\\n if (!(row.account in accountSums)) accountSums[row.account] = 0;\\n amounts[\`\${row.year}/\${row.account}\`] = row.value[ledger.ccy];\\n accountSums[row.account] += row.value[ledger.ccy];\\n}\\n\\nconst accounts = Object.entries(accountSums)\\n .sort(([, a], [, b]) =\\u003e b - a)\\n .map(([name]) =\\u003e name)\\n .slice(0, maxExpenseAccounts)\\n .reverse();\\nreturn {\\n legend: {\\n top: \\"bottom\\",\\n },\\n xAxis: {\\n axisLabel: {\\n formatter: currencyFormat.format,\\n },\\n },\\n yAxis: {\\n data: accounts.map((account) =\\u003e account.split(\\":\\").pop()),\\n },\\n series: years.map((year) =\\u003e ({\\n type: \\"bar\\",\\n name: year,\\n data: accounts.map((account) =\\u003e amounts[\`\${year}/\${account}\`] ?? 0),\\n label: {\\n show: true,\\n position: \\"right\\",\\n formatter: (params) =\\u003e currencyFormat.format(params.value),\\n },\\n })),\\n onClick: (event) =\\u003e {\\n const link = panel.queries[0].link\\n .replaceAll(\\"#\\", \\"%23\\")\\n .replace(\\"{account}\\", accounts[event.dataIndex])\\n .replace(\\"{time}\\", event.seriesName);\\n window.open(link);\\n },\\n};\\n", "title": "Expenses Year-Over-Year \\ud83d\\udcb8", "type": "echarts" },