Skip to content

Commit

Permalink
enhance: net bar graph show net instead of two separate bars (#4033)
Browse files Browse the repository at this point in the history
* enhance: net bar graph show net instead of two separate bars

* chore: note
  • Loading branch information
UnderKoen authored Jan 7, 2025
1 parent bd77dfd commit 1f44903
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
21 changes: 0 additions & 21 deletions packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -311,23 +307,6 @@ export function BarGraph({
/>
))}
</Bar>
{yAxis === 'date' && balanceTypeOp === 'totalTotals' && (
<Bar dataKey="totalDebts" stackId="a">
{viewLabels && !compact && (
<LabelList
dataKey="totalDebts"
content={e => customLabel(e, balanceTypeOp)}
/>
)}
{data[splitData].map((entry, index) => (
<Cell
key={`cell-${index}`}
fill={theme.reportsRed}
name={entry.name}
/>
))}
</Bar>
)}
</BarChart>
</div>
</ResponsiveContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4033.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [UnderKoen]
---

Change net bar graph to show actual net values

0 comments on commit 1f44903

Please sign in to comment.