Skip to content

Commit

Permalink
BarGraph crash (#2411)
Browse files Browse the repository at this point in the history
* Fix crash

* notes
  • Loading branch information
carkom authored Mar 2, 2024
1 parent 40296dc commit a9362cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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) => (
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const renderCustomLabel = (
) => {
return !showLabel || Math.abs(showLabel) > showLabelThreshold ? (
<text
key={fill + display}
x={calcX}
y={calcY}
fill={fill}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2411.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [carkom]
---

Fix crash in the BarGraph for Net/Interval.

0 comments on commit a9362cc

Please sign in to comment.