Skip to content

Commit

Permalink
error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom committed Dec 7, 2023
1 parent 66764db commit b4e1bff
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function ChooseGraph({
style={{ flexGrow: 1 }}
data={data}
groupBy={groupBy}
showEmpty={showEmpty}
balanceTypeOp={balanceTypeOp}
/>
);
Expand All @@ -82,7 +81,6 @@ function ChooseGraph({
style={{ flexGrow: 1 }}
data={data}
groupBy={groupBy}
showEmpty={showEmpty}
balanceTypeOp={balanceTypeOp}
/>
);
Expand Down
48 changes: 20 additions & 28 deletions packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,13 @@ type BarGraphProps = {
data: DataEntity;
groupBy: string;
balanceTypeOp: string;
showEmpty: boolean;
compact?: boolean;
};

function BarGraph({
style,
data,
groupBy,
showEmpty,
balanceTypeOp,
compact,
}: BarGraphProps) {
Expand Down Expand Up @@ -179,9 +177,7 @@ function BarGraph({
width={width}
height={height}
stackOffset="sign"
data={data[splitData].filter(i =>
!showEmpty ? i[balanceTypeOp] !== 0 : true,
)}
data={data[splitData]}
margin={{ top: 0, right: 0, left: 0, bottom: 0 }}
>
{
Expand Down Expand Up @@ -219,33 +215,29 @@ function BarGraph({
<ReferenceLine y={0} stroke={theme.pageTextLight} />
)}
<Bar dataKey={val => getVal(val)} stackId="a">
{data[splitData]
.filter(i => (!showEmpty ? i[balanceTypeOp] !== 0 : true))
.map((entry, index) => (
{data[splitData].map((entry, index) => (
<Cell
key={`cell-${index}`}
fill={
yAxis === 'date'
? balanceTypeOp === 'totalDebts'
? theme.reportsRed
: theme.reportsBlue
: colorScale[index % colorScale.length]
}
name={entry[yAxis]}
/>
))}
</Bar>
{yAxis === 'date' && balanceTypeOp === 'totalTotals' && (
<Bar dataKey={'totalDebts'} stackId="a">
{data[splitData].map((entry, index) => (
<Cell
key={`cell-${index}`}
fill={
yAxis === 'date'
? balanceTypeOp === 'totalDebts'
? theme.reportsRed
: theme.reportsBlue
: colorScale[index % colorScale.length]
}
name={entry[yAxis]}
fill={theme.reportsRed}
name={entry.name}
/>
))}
</Bar>
{yAxis === 'date' && balanceTypeOp === 'totalTotals' && (
<Bar dataKey={'totalDebts'} stackId="a">
{data[splitData]
.filter(i => (!showEmpty ? i[balanceTypeOp] !== 0 : true))
.map((entry, index) => (
<Cell
key={`cell-${index}`}
fill={theme.reportsRed}
name={entry.name}
/>
))}
</Bar>
)}
</BarChart>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ type DonutGraphProps = {
data: DataEntity;
groupBy: string;
balanceTypeOp: string;
showEmpty: boolean;
compact?: boolean;
};

function DonutGraph({
style,
data,
groupBy,
showEmpty,
balanceTypeOp,
compact,
}: DonutGraphProps) {
Expand Down Expand Up @@ -147,9 +145,7 @@ function DonutGraph({
dataKey={val => getVal(val)}
nameKey={yAxis}
isAnimationActive={false}
data={data[splitData].filter(i =>
!showEmpty ? i[balanceTypeOp] !== 0 : true,
)}
data={data[splitData]}
innerRadius={Math.min(width, height) * 0.2}
fill="#8884d8"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ export default function CustomReport() {
selectedCategories,
filters,
conditionsOp,
showEmpty,
showOffBudgetHidden,
showUncategorized,
balanceTypeOp,
});
}, [
startDate,
Expand All @@ -137,6 +139,7 @@ export default function CustomReport() {
selectedCategories,
filters,
conditionsOp,
showEmpty,
showOffBudgetHidden,
showUncategorized,
groupBy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type createSpreadsheetProps = {
selectedCategories: CategoryEntity[];
conditions: RuleConditionEntity[];
conditionsOp: string;
showEmpty: boolean;
showOffBudgetHidden: boolean;
showUncategorized: boolean;
groupBy?: string;
Expand All @@ -41,6 +42,7 @@ export default function createSpreadsheet({
selectedCategories,
conditions = [],
conditionsOp,
showEmpty,
showOffBudgetHidden,
showUncategorized,
groupBy,
Expand Down Expand Up @@ -167,8 +169,10 @@ export default function createSpreadsheet({
});

setData({
data: calcData,
monthData,
data: calcData.filter(i => (!showEmpty ? i[balanceTypeOp] !== 0 : true)),
monthData: monthData.filter(i =>
!showEmpty ? i[balanceTypeOp] !== 0 : true,
),
startDate,
endDate,
totalDebts: integerToAmount(totalDebts),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ function createGroupedSpreadsheet({
selectedCategories,
conditions = [],
conditionsOp,
showEmpty,
showOffBudgetHidden,
showUncategorized,
balanceTypeOp,
}: createSpreadsheetProps) {
const [categoryList, categoryGroup] = categoryLists(
showOffBudgetHidden,
Expand Down Expand Up @@ -140,7 +142,9 @@ function createGroupedSpreadsheet({
[startDate, endDate],
);

setData(groupedData);
setData(
groupedData.filter(i => (!showEmpty ? i[balanceTypeOp] !== 0 : true)),
);
};
}

Expand Down

0 comments on commit b4e1bff

Please sign in to comment.