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 = ({ ...@@ -111,13 +111,17 @@ const CustomTooltip = ({
} }
}; };
const customLabel = props => { const customLabel = (props, typeOp) => {
const calcX = props.x + props.width / 2; const calcX = props.x + props.width / 2;
const calcY = props.y - (props.value > 0 ? 15 : -15); const calcY = props.y - (props.value > 0 ? 15 : -15);
const textAnchor = 'middle'; const textAnchor = 'middle';
const display = const display =
props.value !== 0 && `${amountToCurrencyNoDecimal(props.value)}`; 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); return renderCustomLabel(calcX, calcY, textAnchor, display, textSize);
}; };
...@@ -226,7 +230,7 @@ export function BarGraph({ ...@@ -226,7 +230,7 @@ export function BarGraph({
{viewLabels && !compact && ( {viewLabels && !compact && (
<LabelList <LabelList
dataKey={val => getVal(val)} dataKey={val => getVal(val)}
content={customLabel} content={e => customLabel(e, balanceTypeOp)}
/> />
)} )}
{data.legend.map((entry, index) => ( {data.legend.map((entry, index) => (
...@@ -240,7 +244,10 @@ export function BarGraph({ ...@@ -240,7 +244,10 @@ export function BarGraph({
{yAxis === 'date' && balanceTypeOp === 'totalTotals' && ( {yAxis === 'date' && balanceTypeOp === 'totalTotals' && (
<Bar dataKey="totalDebts" stackId="a"> <Bar dataKey="totalDebts" stackId="a">
{viewLabels && !compact && ( {viewLabels && !compact && (
<LabelList dataKey="totalDebts" content={customLabel} /> <LabelList
dataKey="totalDebts"
content={e => customLabel(e, balanceTypeOp)}
/>
)} )}
{data[splitData].map((entry, index) => ( {data[splitData].map((entry, index) => (
<Cell <Cell
......
...@@ -16,6 +16,7 @@ export const renderCustomLabel = ( ...@@ -16,6 +16,7 @@ export const renderCustomLabel = (
) => { ) => {
return !showLabel || Math.abs(showLabel) > showLabelThreshold ? ( return !showLabel || Math.abs(showLabel) > showLabelThreshold ? (
<text <text
key={fill + display}
x={calcX} x={calcX}
y={calcY} y={calcY}
fill={fill} 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