diff --git a/packages/desktop-client/src/components/reports/Custom.js b/packages/desktop-client/src/components/reports/Custom.js
index 56a64f72173..44e141388b4 100644
--- a/packages/desktop-client/src/components/reports/Custom.js
+++ b/packages/desktop-client/src/components/reports/Custom.js
@@ -114,13 +114,14 @@ export default function Custom() {
} = useFilters();
const typeOptions = [
- { value: 1, description: 'Debts', format: 'totalDebts' },
- { value: 2, description: 'Assets', format: 'totalAssets' },
+ { value: 1, description: 'Expense', format: 'totalDebts' },
+ { value: 2, description: 'Income', format: 'totalAssets' },
{ value: 3, description: 'Net', format: 'totalTotals' },
];
const [selectedCategories, setSelectedCategories] = useState(null);
const [allMonths, setAllMonths] = useState(null);
+ const [typeDisabled, setTypeDisabled] = useState([3]);
const [start, setStart] = useState(
monthUtils.subMonths(monthUtils.currentMonth(), 5),
);
@@ -331,6 +332,14 @@ export default function Custom() {
function onChangeMode(cond) {
setMode(cond);
if (cond === 'time') {
+ if (graphType === 'TableGraph') {
+ setTypeDisabled([0]);
+ } else {
+ setTypeDisabled([3]);
+ if ([3].includes(type)) {
+ setType(1);
+ }
+ }
if (graphType === 'BarGraph') {
setGraphType('StackedBarGraph');
}
@@ -341,18 +350,25 @@ export default function Custom() {
if ([5, 6].includes(split)) {
setSplit(1);
}
- if ([3].includes(type)) {
- setType(1);
- }
} else {
if (graphType === 'StackedBarGraph') {
setGraphType('BarGraph');
+ } else {
+ setTypeDisabled([0]);
}
}
}
- function onChangeGraph(cond) {
- setGraphType(cond);
+ function onChangeSplit(cond) {
+ setSplit(cond);
+ if (mode === 'total') {
+ if (graphType !== 'TableGraph') {
+ setTypeDisabled(![5, 6].includes(split) ? [0] : [3]);
+ }
+ }
+ if ([3].includes(type) && graphType !== 'TableGraph') {
+ setType(1);
+ }
}
function GraphButton({
@@ -464,277 +480,273 @@ export default function Custom() {
flexShrink: 0,
}}
>
-
-
- Display
-
-
-
-
- Mode:
-
- onChangeMode('total')}
+
+
- Total
-
- onChangeMode('time')}
+
+ Display
+
+
+
- Time
-
-
-
-
- Split:
-
-
-
-
- Type:
-
-
- {/*
-
-
- Interval:
-
-
- */}
-
-
+
+ Mode:
+
+ onChangeMode('total')}
+ >
+ Total
+
+ onChangeMode('time')}
+ >
+ Time
+
+
+
+
+ Split:
+
+
+
+
+ Type:
+
+
+ {/*
+
+
+ Interval:
+
+
+ */}
+
+
- setEmpty(!empty)}
- />
-
+
- Show Empty Rows
-
-
-
-
+
- setHidden(!hidden)}
- />
- setHidden(!hidden)}
+ />
+
+ Off Budget Items
+
+
+
- Off Budget Items
-
-
-
-
+
- setUncat(!uncat)}
+ setUncat(!uncat)}
+ />
+
+ Uncategorized
+
+
+
-
- Uncategorized
-
-
-
-
-
- Date filters
-
-
-
-
- Range:
-
-
+
+
+ Range:
+
+
+
+
+ From:
+
+
+
+
+ To:
+
+
+ [
- option.value,
- option.description,
- ])}
- line={dateRangeLine}
- />
-
-
-
- From:
-
-
-
-
- To:
-
-
-
{[1, 2].includes(split) && (
{
- onChangeGraph('TableGraph');
+ setGraphType('TableGraph');
setViewSplit(false);
+ setTypeDisabled([0]);
}}
>
@@ -779,11 +792,14 @@ export default function Custom() {
}
onSelect={() => {
if (mode === 'total') {
- onChangeGraph('BarGraph');
+ setGraphType('BarGraph');
// eslint-disable-next-line rulesdir/prefer-if-statement
[3].includes(type) && setType(1);
+ setTypeDisabled([5, 6].includes(split) ? [0] : [3]);
} else {
- onChangeGraph('StackedBarGraph');
+ setGraphType('StackedBarGraph');
+ setTypeDisabled([3]);
+ setType(1);
}
}}
style={{ marginLeft: 15 }}
@@ -794,9 +810,10 @@ export default function Custom() {
title="Area Graph"
selected={graphType === 'AreaGraph'}
onSelect={() => {
- onChangeGraph('AreaGraph');
+ setGraphType('AreaGraph');
setSplit(5);
setViewSplit(false);
+ setTypeDisabled([0]);
}}
style={{ marginLeft: 15 }}
disabled={mode === 'total' ? false : true}
@@ -807,8 +824,9 @@ export default function Custom() {
title="Donut Graph"
selected={graphType === 'DonutGraph'}
onSelect={() => {
- onChangeGraph('DonutGraph');
- //setType(1);
+ setGraphType('DonutGraph');
+ setTypeDisabled([3]);
+ setType(1);
}}
style={{ marginLeft: 15 }}
disabled={mode === 'total' ? false : true}
diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
index 08b71133cd7..6bc77975f50 100644
--- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
@@ -96,22 +96,28 @@ function AreaGraph({ style, data, typeOp, compact }: AreaGraphProps) {
-
-
-
- {amountToCurrency(payload[0].payload.totalTotals)}
-
- }
- />
+ {['totalAssets', 'totalTotals'].includes(typeOp) && (
+
+ )}
+ {['totalDebts', 'totalTotals'].includes(typeOp) && (
+
+ )}
+ {['totalTotals'].includes(typeOp) && (
+
+ {amountToCurrency(payload[0].payload.totalTotals)}
+
+ }
+ />
+ )}
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index 04683836ad7..a7597de405f 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -78,12 +78,6 @@ function BarGraph({
};
};
- type CustomTooltipProps = {
- active?: boolean;
- payload?: PayloadItem[];
- label?: string;
- };
-
type CustomLegendProps = {
active?: boolean;
payload?: PayloadItem[];
@@ -103,6 +97,12 @@ function BarGraph({
return ;
};
+ type CustomTooltipProps = {
+ active?: boolean;
+ payload?: PayloadItem[];
+ label?: string;
+ };
+
const CustomTooltip = ({ active, payload, label }: CustomTooltipProps) => {
if (active && payload && payload.length) {
return (
@@ -126,26 +126,28 @@ function BarGraph({
-
-
-
-
- {amountToCurrency(payload[0].payload.totalChange)}
-
- }
- />
+ {['totalAssets', 'totalTotals'].includes(typeOp) && (
+
+ )}
+ {['totalDebts', 'totalTotals'].includes(typeOp) && (
+
+ )}
+ {['totalTotals'].includes(typeOp) && (
+
+ {amountToCurrency(payload[0].payload.totalTotals)}
+
+ }
+ />
+ )}
@@ -162,6 +164,10 @@ function BarGraph({
}
};
+ const longestLabelLength = data[splitData]
+ .map(c => c[yAxis])
+ .reduce((acc, cur) => (cur.length > acc ? cur.length : acc), 0);
+
return (
{!compact && }
- {!compact && }
+ {!compact && (
+
+ )}
{!compact && }
{!compact && }
getVal(val)} stackId="a">