diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx index 5513dc44cbd..e32a8414419 100644 --- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx @@ -186,10 +186,6 @@ export function BarGraph({ const labelsMargin = viewLabels ? 30 : 0; const getVal = obj => { - if (balanceTypeOp === 'totalTotals' && groupBy === 'Interval') { - return obj.totalAssets; - } - if (['totalDebts', 'netDebts'].includes(balanceTypeOp)) { return -1 * obj[balanceTypeOp]; } @@ -311,23 +307,6 @@ export function BarGraph({ /> ))} - {yAxis === 'date' && balanceTypeOp === 'totalTotals' && ( - - {viewLabels && !compact && ( - customLabel(e, balanceTypeOp)} - /> - )} - {data[splitData].map((entry, index) => ( - - ))} - - )} diff --git a/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts b/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts index 93a80014fee..8b8acc44d5a 100644 --- a/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts +++ b/packages/desktop-client/src/components/reports/spreadsheets/calculateLegend.ts @@ -19,24 +19,41 @@ export function calculateLegend( const chooseData = groupBy === 'Interval' ? intervalData.map(c => { - return { name: c.date, id: null }; + return { name: c.date, id: null, data: c }; }) : calcDataFiltered.map(c => { - return { name: c.name, id: c.id }; + return { name: c.name, id: c.id, data: c }; }); + function getColor(data: IntervalEntity, index: number) { + if (graphType === 'DonutGraph') { + return colorScale[index % colorScale.length]; + } + + if (groupBy === 'Interval') { + if (balanceTypeOp === 'totalDebts') { + return theme.reportsRed; + } + + if (balanceTypeOp === 'totalTotals') { + if (data.totalTotals < 0) { + return theme.reportsRed; + } + + return theme.reportsBlue; + } + + return theme.reportsBlue; + } + + return colorScale[index % colorScale.length]; + } + const legend: LegendEntity[] = chooseData.map((item, index) => { return { id: item.id || '', name: item.name || '', - color: - graphType === 'DonutGraph' - ? colorScale[index % colorScale.length] - : groupBy === 'Interval' - ? balanceTypeOp === 'totalDebts' - ? theme.reportsRed - : theme.reportsBlue - : colorScale[index % colorScale.length], + color: getColor(item.data, index), }; }); return legend; diff --git a/upcoming-release-notes/4033.md b/upcoming-release-notes/4033.md new file mode 100644 index 00000000000..eb71b5726db --- /dev/null +++ b/upcoming-release-notes/4033.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [UnderKoen] +--- + +Change net bar graph to show actual net values