A local-first personal finance app
fix: number format config not being respected for graphs (#2832)
Sreetam Dasd032fce7ea70
diff --git a/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsxindex ffdac1e016..c7e5ec785a 100644--- a/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx@@ -13,6 +13,8 @@ import {ResponsiveContainer,} from 'recharts';+import { amountToCurrencyNoDecimal } from 'loot-core/shared/util';+import { theme } from '../../../style';import { type CSSProperties } from '../../../style';import { AlignedText } from '../../common/AlignedText';@@ -77,7 +79,7 @@ type BarLineGraphProps = {export function BarLineGraph({ style, data, compact }: BarLineGraphProps) {const tickFormatter = tick => {- return `${Math.round(tick).toLocaleString()}`; // Formats the tick values as strings with commas+ return `${amountToCurrencyNoDecimal(Math.round(tick))}`; // Formats the tick values as strings with commas};return (diff --git a/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx b/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsxindex 98353b3139..3d84d5968f 100644--- a/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx+++ b/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx@@ -12,6 +12,8 @@ import {ResponsiveContainer,} from 'recharts';+import { amountToCurrencyNoDecimal } from 'loot-core/shared/util';+import { usePrivacyMode } from '../../../hooks/usePrivacyMode';import { useResponsive } from '../../../ResponsiveProvider';import { theme } from '../../../style';@@ -35,7 +37,11 @@ export function NetWorthGraph({const { isNarrowWidth } = useResponsive();const tickFormatter = tick => {- return privacyMode ? '...' : `${Math.round(tick).toLocaleString()}`; // Formats the tick values as strings with commas+ const res = privacyMode+ ? '...'+ : `${amountToCurrencyNoDecimal(Math.round(tick))}`; // Formats the tick values as strings with commas++ return res;};const gradientOffset = () => {@@ -197,7 +203,7 @@ function computePadding(netWorthData: Array<{ y: number }>) {*/const maxLength = Math.max(...netWorthData.map(({ y }) => {- return Math.round(y).toLocaleString().length;+ return amountToCurrencyNoDecimal(Math.round(y)).length;}),);diff --git a/packages/loot-core/src/shared/util.ts b/packages/loot-core/src/shared/util.tsindex 7a45a48f88..0f2a10c10d 100644--- a/packages/loot-core/src/shared/util.ts+++ b/packages/loot-core/src/shared/util.ts@@ -341,7 +341,10 @@ export function amountToCurrency(n) {}export function amountToCurrencyNoDecimal(n) {- return getNumberFormat({ hideFraction: true }).formatter.format(n);+ return getNumberFormat({+ ...numberFormatConfig,+ hideFraction: true,+ }).formatter.format(n);}export function currencyToAmount(str: string) {diff --git a/upcoming-release-notes/2832.md b/upcoming-release-notes/2832.mdnew file mode 100644index 0000000000..73ba6d988a--- /dev/null+++ b/upcoming-release-notes/2832.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [sreetamdas]+---++Fix number format preference not being used for graphs