Skip to content
Snippets Groups Projects
Unverified Commit a9362cc6 authored by Neil's avatar Neil Committed by GitHub
Browse files

BarGraph crash (#2411)

* Fix crash

* notes
parent 40296dc8
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -16,6 +16,7 @@ export const renderCustomLabel = (
) => {
return !showLabel || Math.abs(showLabel) > showLabelThreshold ? (
<text
key={fill + display}
x={calcX}
y={calcY}
fill={fill}
......
---
category: Bugfix
authors: [carkom]
---
Fix crash in the BarGraph for Net/Interval.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment