Skip to content

A local-first personal finance app

BarGraph crash (#2411)

Neila9362cc6f9b9
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index 5ec4783c19..16e51f2628 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -111,13 +111,17 @@ const CustomTooltip = ({
}
};
-const customLabel = props => {
+const customLabel = (props, typeOp) => {
const calcX = props.x + props.width / 2;
const calcY = props.y - (props.value > 0 ? 15 : -15);
const textAnchor = 'middle';
const display =
props.value !== 0 && `${amountToCurrencyNoDecimal(props.value)}`;
- const textSize = adjustTextSize(props.width, 'variable', props.value);
+ const textSize = adjustTextSize(
+ props.width,
+ typeOp === 'totalTotals' ? 'default' : 'variable',
+ props.value,
+ );
return renderCustomLabel(calcX, calcY, textAnchor, display, textSize);
};
@@ -226,7 +230,7 @@ export function BarGraph({
{viewLabels && !compact && (
<LabelList
dataKey={val => getVal(val)}
- content={customLabel}
+ content={e => customLabel(e, balanceTypeOp)}
/>
)}
{data.legend.map((entry, index) => (
@@ -240,7 +244,10 @@ export function BarGraph({
{yAxis === 'date' && balanceTypeOp === 'totalTotals' && (
<Bar dataKey="totalDebts" stackId="a">
{viewLabels && !compact && (
- <LabelList dataKey="totalDebts" content={customLabel} />
+ <LabelList
+ dataKey="totalDebts"
+ content={e => customLabel(e, balanceTypeOp)}
+ />
)}
{data[splitData].map((entry, index) => (
<Cell
diff --git a/packages/desktop-client/src/components/reports/graphs/renderCustomLabel.tsx b/packages/desktop-client/src/components/reports/graphs/renderCustomLabel.tsx
index 187b50394a..103561f7fc 100644
--- a/packages/desktop-client/src/components/reports/graphs/renderCustomLabel.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/renderCustomLabel.tsx
@@ -16,6 +16,7 @@ export const renderCustomLabel = (
) => {
return !showLabel || Math.abs(showLabel) > showLabelThreshold ? (
<text
+ key={fill + display}
x={calcX}
y={calcY}
fill={fill}
diff --git a/upcoming-release-notes/2411.md b/upcoming-release-notes/2411.md
new file mode 100644
index 0000000000..03ae4ba8bb
--- /dev/null
+++ b/upcoming-release-notes/2411.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [carkom]
+---
+
+Fix crash in the BarGraph for Net/Interval.