diff --git a/packages/desktop-client/src/components/reports/Custom.js b/packages/desktop-client/src/components/reports/Custom.js index c0fd1d8bd2b..02a48175190 100644 --- a/packages/desktop-client/src/components/reports/Custom.js +++ b/packages/desktop-client/src/components/reports/Custom.js @@ -187,6 +187,7 @@ export default function Custom() { end={end} data={data} split={split} + empty={empty} OnChangeLegend={OnChangeLegend} typeOp={typeOptions.find(opt => opt.value === type).format} /> @@ -210,6 +211,7 @@ export default function Custom() { end={end} data={data} split={split} + empty={empty} OnChangeLegend={OnChangeLegend} typeOp={typeOptions.find(opt => opt.value === type).format} /> @@ -259,18 +261,21 @@ export default function Custom() { function onChangeMode(cond) { setMode(cond); - if (graphType === 'StackedBarGraph' && cond === 'total') { - setGraphType('BarGraph'); - } - if (graphType === 'BarGraph' && cond === 'time') { - setGraphType('StackedBarGraph'); - } - if ( - cond === 'time' && - (graphType === 'AreaGraph' || graphType === 'DonutGraph') - ) { - setGraphType('TableGraph'); - setViewSplit(false); + if (cond === 'time') { + if (graphType === 'BarGraph') { + setGraphType('StackedBarGraph'); + } + if (['AreaGraph', 'DonutGraph'].includes(graphType)) { + setGraphType('TableGraph'); + setViewSplit(false); + } + if ([5, 6].includes(split)) { + setSplit(1); + } + } else { + if (graphType === 'StackedBarGraph') { + setGraphType('BarGraph'); + } } } diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx index 83e1f2c0433..d5b9b20079d 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx @@ -27,6 +27,7 @@ type BarGraphProps = { data; split; typeOp; + empty; OnChangeLegend; compact: boolean; domain?: { @@ -46,6 +47,7 @@ function BarGraph({ style, data, split, + empty, typeOp, OnChangeLegend, compact, @@ -63,6 +65,10 @@ function BarGraph({ totalTotals: number | string; networth: number | string; totalChange: number | string; + children: { + fill: string; + name: string; + }; }; }; @@ -79,14 +85,14 @@ function BarGraph({ }; const CustomLegend = ({ active, payload, label }: CustomLegendProps) => { - const agg = payload.map(leg => { + const agg = payload[0].payload.children.map(leg => { return { - name: leg.value, - //color: leg.color, + name: leg.props.name, + color: leg.props.fill, }; }); - OnChangeLegend(agg); + OnChangeLegend(agg.slice(0).reverse()); return
; }; @@ -157,7 +163,13 @@ function BarGraph({