Skip to content

Commit 2c1967d

Browse files
authored
♻️ (reports) add 'showTooltip' prop to various graphs (#3200)
1 parent 798aee7 commit 2c1967d

File tree

8 files changed

+52
-13
lines changed

8 files changed

+52
-13
lines changed

packages/desktop-client/src/components/reports/ChooseGraph.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type ChooseGraphProps = {
2929
style?: CSSProperties;
3030
showHiddenCategories?: boolean;
3131
showOffBudget?: boolean;
32+
showTooltip?: boolean;
3233
intervalsCount: number;
3334
};
3435

@@ -46,6 +47,7 @@ export function ChooseGraph({
4647
style,
4748
showHiddenCategories = false,
4849
showOffBudget = false,
50+
showTooltip = true,
4951
intervalsCount,
5052
}: ChooseGraphProps) {
5153
const graphStyle = compact
@@ -102,6 +104,7 @@ export function ChooseGraph({
102104
data={data}
103105
balanceTypeOp={balanceTypeOp}
104106
viewLabels={viewLabels}
107+
showTooltip={showTooltip}
105108
/>
106109
);
107110
}
@@ -117,11 +120,19 @@ export function ChooseGraph({
117120
viewLabels={viewLabels}
118121
showHiddenCategories={showHiddenCategories}
119122
showOffBudget={showOffBudget}
123+
showTooltip={showTooltip}
120124
/>
121125
);
122126
}
123127
if (graphType === 'BarLineGraph') {
124-
return <BarLineGraph style={graphStyle} compact={compact} data={data} />;
128+
return (
129+
<BarLineGraph
130+
style={graphStyle}
131+
compact={compact}
132+
data={data}
133+
showTooltip={showTooltip}
134+
/>
135+
);
125136
}
126137
if (graphType === 'DonutGraph') {
127138
return (
@@ -149,6 +160,7 @@ export function ChooseGraph({
149160
balanceTypeOp={balanceTypeOp}
150161
showHiddenCategories={showHiddenCategories}
151162
showOffBudget={showOffBudget}
163+
showTooltip={showTooltip}
152164
interval={interval}
153165
/>
154166
);
@@ -165,6 +177,7 @@ export function ChooseGraph({
165177
groupBy={groupBy}
166178
showHiddenCategories={showHiddenCategories}
167179
showOffBudget={showOffBudget}
180+
showTooltip={showTooltip}
168181
interval={interval}
169182
/>
170183
);

packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from 'loot-core/src/types/models/reports';
2323

2424
import { usePrivacyMode } from '../../../hooks/usePrivacyMode';
25-
import { useResponsive } from '../../../ResponsiveProvider';
2625
import { theme } from '../../../style';
2726
import { type CSSProperties } from '../../../style';
2827
import { AlignedText } from '../../common/AlignedText';
@@ -152,6 +151,7 @@ type AreaGraphProps = {
152151
balanceTypeOp: balanceTypeOpType;
153152
compact?: boolean;
154153
viewLabels: boolean;
154+
showTooltip?: boolean;
155155
};
156156

157157
export function AreaGraph({
@@ -160,9 +160,9 @@ export function AreaGraph({
160160
balanceTypeOp,
161161
compact,
162162
viewLabels,
163+
showTooltip = true,
163164
}: AreaGraphProps) {
164165
const privacyMode = usePrivacyMode();
165-
const { isNarrowWidth } = useResponsive();
166166
const dataMax = Math.max(...data.intervalData.map(i => i[balanceTypeOp]));
167167
const dataMin = Math.min(...data.intervalData.map(i => i[balanceTypeOp]));
168168

@@ -249,7 +249,7 @@ export function AreaGraph({
249249
tickSize={0}
250250
/>
251251
)}
252-
{(!isNarrowWidth || !compact) && (
252+
{showTooltip && (
253253
<Tooltip
254254
content={<CustomTooltip balanceTypeOp={balanceTypeOp} />}
255255
isAnimationActive={false}

packages/desktop-client/src/components/reports/graphs/BarGraph.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ type BarGraphProps = {
159159
viewLabels: boolean;
160160
showHiddenCategories?: boolean;
161161
showOffBudget?: boolean;
162+
showTooltip?: boolean;
162163
};
163164

164165
export function BarGraph({
@@ -171,6 +172,7 @@ export function BarGraph({
171172
viewLabels,
172173
showHiddenCategories,
173174
showOffBudget,
175+
showTooltip = true,
174176
}: BarGraphProps) {
175177
const navigate = useNavigate();
176178
const categories = useCategories();
@@ -230,7 +232,7 @@ export function BarGraph({
230232
bottom: 0,
231233
}}
232234
>
233-
{(!isNarrowWidth || !compact) && (
235+
{showTooltip && (
234236
<Tooltip
235237
cursor={{ fill: 'transparent' }}
236238
content={

packages/desktop-client/src/components/reports/graphs/BarLineGraph.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ type BarLineGraphProps = {
7575
style?: CSSProperties;
7676
data;
7777
compact?: boolean;
78+
showTooltip?: boolean;
7879
};
7980

80-
export function BarLineGraph({ style, data, compact }: BarLineGraphProps) {
81+
export function BarLineGraph({
82+
style,
83+
data,
84+
compact,
85+
showTooltip = true,
86+
}: BarLineGraphProps) {
8187
const tickFormatter = tick => {
8288
return `${amountToCurrencyNoDecimal(Math.round(tick))}`; // Formats the tick values as strings with commas
8389
};
@@ -100,11 +106,13 @@ export function BarLineGraph({ style, data, compact }: BarLineGraphProps) {
100106
data={data.data}
101107
margin={{ top: 0, right: 0, left: 0, bottom: 0 }}
102108
>
103-
<Tooltip
104-
content={<CustomTooltip />}
105-
formatter={numberFormatterTooltip}
106-
isAnimationActive={false}
107-
/>
109+
{showTooltip && (
110+
<Tooltip
111+
content={<CustomTooltip />}
112+
formatter={numberFormatterTooltip}
113+
isAnimationActive={false}
114+
/>
115+
)}
108116
{!compact && (
109117
<>
110118
<CartesianGrid strokeDasharray="3 3" />

packages/desktop-client/src/components/reports/graphs/LineGraph.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type LineGraphProps = {
121121
balanceTypeOp: balanceTypeOpType;
122122
showHiddenCategories?: boolean;
123123
showOffBudget?: boolean;
124+
showTooltip?: boolean;
124125
interval?: string;
125126
};
126127

@@ -133,6 +134,7 @@ export function LineGraph({
133134
balanceTypeOp,
134135
showHiddenCategories,
135136
showOffBudget,
137+
showTooltip = true,
136138
interval,
137139
}: LineGraphProps) {
138140
const navigate = useNavigate();
@@ -186,7 +188,7 @@ export function LineGraph({
186188
margin={{ top: 10, right: 10, left: leftMargin, bottom: 10 }}
187189
style={{ cursor: pointer }}
188190
>
189-
{(!isNarrowWidth || !compact) && (
191+
{showTooltip && (
190192
<Tooltip
191193
content={
192194
<CustomTooltip compact={compact} tooltip={tooltip} />

packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ type StackedBarGraphProps = {
150150
balanceTypeOp: balanceTypeOpType;
151151
showHiddenCategories?: boolean;
152152
showOffBudget?: boolean;
153+
showTooltip?: boolean;
153154
interval?: string;
154155
};
155156

@@ -163,6 +164,7 @@ export function StackedBarGraph({
163164
balanceTypeOp,
164165
showHiddenCategories,
165166
showOffBudget,
167+
showTooltip = true,
166168
interval,
167169
}: StackedBarGraphProps) {
168170
const navigate = useNavigate();
@@ -199,7 +201,7 @@ export function StackedBarGraph({
199201
style={{ cursor: pointer }}
200202
stackOffset="sign" //stacked by sign
201203
>
202-
{(!isNarrowWidth || !compact) && (
204+
{showTooltip && (
203205
<Tooltip
204206
content={
205207
<CustomTooltip compact={compact} tooltip={tooltip} />

packages/desktop-client/src/components/reports/reports/GetCardData.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { type PayeeEntity } from 'loot-core/types/models/payee';
99
import { type CustomReportEntity } from 'loot-core/types/models/reports';
1010
import { type LocalPrefs } from 'loot-core/types/prefs';
1111

12+
import { useResponsive } from '../../../ResponsiveProvider';
1213
import { styles } from '../../../style/styles';
1314
import { theme } from '../../../style/theme';
1415
import { Text } from '../../common/Text';
@@ -66,14 +67,18 @@ export function GetCardData({
6667
categories,
6768
earliestTransaction,
6869
firstDayOfWeekIdx,
70+
showTooltip,
6971
}: {
7072
report: CustomReportEntity;
7173
payees: PayeeEntity[];
7274
accounts: AccountEntity[];
7375
categories: { list: CategoryEntity[]; grouped: CategoryGroupEntity[] };
7476
earliestTransaction: string;
7577
firstDayOfWeekIdx?: LocalPrefs['firstDayOfWeekIdx'];
78+
showTooltip?: boolean;
7679
}) {
80+
const { isNarrowWidth } = useResponsive();
81+
7782
let startDate = report.startDate;
7883
let endDate = report.endDate;
7984

@@ -170,6 +175,7 @@ export function GetCardData({
170175
compact={true}
171176
style={{ height: 'auto', flex: 1 }}
172177
intervalsCount={intervals.length}
178+
showTooltip={!isNarrowWidth && showTooltip}
173179
/>
174180
</ErrorBoundary>
175181
) : (

upcoming-release-notes/3200.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Maintenance
3+
authors: [MatissJanis]
4+
---
5+
6+
Reports: add `showTooltip` prop for controlling tooltip visibility.

0 commit comments

Comments
 (0)