A local-first personal finance app
[AI] Fix balance forecast report Y-axis label clipping (#8030)
Sebastián Maluk964f10fd5864
diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-1-chromium-linux.pngindex dcfed8eabd..28cbd5756c 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-2-chromium-linux.pngindex 98690d8c84..d5703db181 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-3-chromium-linux.pngindex 28bd85fc5e..943279b597 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-3-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-loads-balance-forecast-report-with-monthly-granularity-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-1-chromium-linux.pngindex 80664bf460..5e750aad7d 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-2-chromium-linux.pngindex 3b640bd0f2..1f5928d691 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-3-chromium-linux.pngindex 0666df3bcc..ebcffd5de9 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-3-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-balance-forecast-switches-to-daily-granularity-3-chromium-linux.png differdiff --git a/packages/desktop-client/package.json b/packages/desktop-client/package.jsonindex d6c7be6936..67582d7fb3 100644--- a/packages/desktop-client/package.json+++ b/packages/desktop-client/package.json@@ -59,6 +59,7 @@"#components/reports/getCustomTick": "./src/components/reports/getCustomTick.ts","#components/reports/getLiveRange": "./src/components/reports/getLiveRange.ts","#components/reports/graphs/showActivity": "./src/components/reports/graphs/showActivity.ts",+ "#components/reports/graphs/util/computePadding": "./src/components/reports/graphs/util/computePadding.ts","#components/reports/numberFormatter": "./src/components/reports/numberFormatter.ts","#components/reports/ReportOptions": "./src/components/reports/ReportOptions.ts","#components/reports/reportRanges": "./src/components/reports/reportRanges.ts",diff --git a/packages/desktop-client/src/components/reports/reports/BalanceForecast.tsx b/packages/desktop-client/src/components/reports/reports/BalanceForecast.tsxindex 578b5becb1..dc60e1d94d 100644--- a/packages/desktop-client/src/components/reports/reports/BalanceForecast.tsx+++ b/packages/desktop-client/src/components/reports/reports/BalanceForecast.tsx@@ -31,6 +31,7 @@ import { Page, PageHeader } from '#components/Page';import { PrivacyFilter } from '#components/PrivacyFilter';import { Container } from '#components/reports/Container';import { getCustomTick } from '#components/reports/getCustomTick';+import { computePadding } from '#components/reports/graphs/util/computePadding';import { Header } from '#components/reports/Header';import { LoadingIndicator } from '#components/reports/LoadingIndicator';import { useAccounts } from '#hooks/useAccounts';@@ -266,6 +267,12 @@ function BalanceForecastInner({ widget }: BalanceForecastInnerProps) {end: chartRange.end,granularity,});+ const formatYTick = (value: number) =>+ getCustomTick(format(value, 'financial-no-decimals'), privacyMode);+ const yAxisLeftPadding = computePadding(+ chartData.map(point => point.balance),+ formatYTick,+ );const isUpdatingForecast = isFetching && isPlaceholderData;const scheduledOccurrenceCount = countForecastScheduledOccurrences(@@ -398,7 +405,12 @@ function BalanceForecastInner({ widget }: BalanceForecastInnerProps) {width={width}height={height}data={chartData}- margin={{ top: 10, right: 10, left: 5, bottom: 10 }}+ margin={{+ top: 10,+ right: 10,+ left: 5 + yAxisLeftPadding,+ bottom: 10,+ }}><defs><linearGradient@@ -453,12 +465,7 @@ function BalanceForecastInner({ widget }: BalanceForecastInnerProps) {/><YAxisdomain={['auto', 'auto']}- tickFormatter={value =>- getCustomTick(- format(value, 'financial-no-decimals'),- privacyMode,- )- }+ tickFormatter={formatYTick}tick={{ fill: theme.pageText }}tickLine={{ stroke: theme.pageText }}tickSize={0}diff --git a/upcoming-release-notes/8030.md b/upcoming-release-notes/8030.mdnew file mode 100644index 0000000000..c137950d98--- /dev/null+++ b/upcoming-release-notes/8030.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [samaluk]+---++Fix Balance Forecast report Y-axis numbers being cut off for large balances.