Skip to content

Commit

Permalink
update example dashboard: show travels with most recent expense at bo…
Browse files Browse the repository at this point in the history
…ttom
  • Loading branch information
andreasgerstmayr committed Sep 11, 2023
1 parent 7eb6635 commit feaccc2
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 100 deletions.
8 changes: 4 additions & 4 deletions example/dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dashboards:
currency: ledger.ccy,
maximumFractionDigits: 0,
});
const value = panel.queries[0].result[0].value[ledger.ccy];
const value = panel.queries[0].result[0]?.value[ledger.ccy];
const valueFmt = currencyFormat.format(value ?? 0);
return `<div style="font-size: 40px; font-weight: bold; color: #3daf46; text-align: center;">${valueFmt}</div>`;
Expand All @@ -29,7 +29,7 @@ dashboards:
currency: ledger.ccy,
maximumFractionDigits: 0,
});
const value = panel.queries[0].result[0].value[ledger.ccy];
const value = panel.queries[0].result[0]?.value[ledger.ccy];
const valueFmt = currencyFormat.format(value ? -value : 0);
return `<div style="font-size: 40px; font-weight: bold; color: #af3d3d; text-align: center;">${valueFmt}</div>`;
Expand Down Expand Up @@ -882,7 +882,7 @@ dashboards:
- bql: |
SELECT tags, CONVERT(position, '{{ledger.ccy}}') AS value
WHERE account ~ '^Expenses:' AND 'travel' IN tags
ORDER BY date, tags
ORDER BY date, tags DESC
link: /beancount/account/Expenses/?filter=#{travel}
type: echarts
script: |
Expand All @@ -897,7 +897,7 @@ dashboards:
for (let row of panel.queries[0].result) {
const tag = row.tags.find((tag) => tag.match(/\-\d{4}/));
if (!(tag in amounts)) {
travels.unshift(tag);
travels.push(tag);
amounts[tag] = 0;
}
amounts[tag] += row.value.number;
Expand Down
Binary file modified frontend/tests/e2e/__image_snapshots__/dashboard_travelling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit feaccc2

Please sign in to comment.