Skip to content

A local-first personal finance app

Fix budget analysis report padding (#7118)

Mats Nilsson295a565e5569
diff --git a/packages/desktop-client/src/components/reports/graphs/BudgetAnalysisGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BudgetAnalysisGraph.tsx
index ee7574b718..a59f794bb8 100644
--- a/packages/desktop-client/src/components/reports/graphs/BudgetAnalysisGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BudgetAnalysisGraph.tsx
@@ -18,6 +18,8 @@ import {
import * as monthUtils from 'loot-core/shared/months';
+import { computePadding } from './util/computePadding';
+
import { FinancialText } from '@desktop-client/components/FinancialText';
import { Container } from '@desktop-client/components/reports/Container';
import { useFormat } from '@desktop-client/hooks/useFormat';
@@ -220,11 +222,22 @@ export function BudgetAnalysisGraph({
return monthUtils.format(date, 'MMM d', locale);
};
+ const allValues = graphData.flatMap(item => [
+ item.budgeted,
+ item.spent,
+ item.balance,
+ item.overspendingAdjustment,
+ ]);
+
+ const leftPadding = computePadding(allValues, value =>
+ format(value, 'financial-no-decimals'),
+ );
+
const commonProps = {
width: 0,
height: 0,
data: graphData,
- margin: { top: 5, right: 5, left: 5, bottom: 5 },
+ margin: { top: 5, right: 5, left: 5 + leftPadding, bottom: 5 },
};
return (
diff --git a/upcoming-release-notes/7118.md b/upcoming-release-notes/7118.md
new file mode 100644
index 0000000000..20a75c2a14
--- /dev/null
+++ b/upcoming-release-notes/7118.md
@@ -0,0 +1,6 @@
+---
+category: Bugfixes
+authors: [mnil]
+---
+
+Fix budget analysis report padding when the value is large.