Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Experimental feature: Sankey chart #4142

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/desktop-client/src/components/reports/ChooseGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { StackedBarGraph } from './graphs/StackedBarGraph';
import { ReportTable } from './graphs/tableGraph/ReportTable';
import { ReportOptions } from './ReportOptions';
import { SankeyGraph } from './graphs/SankeyGraph';

Check warning on line 16 in packages/desktop-client/src/components/reports/ChooseGraph.tsx

View workflow job for this annotation

GitHub Actions / lint

`./graphs/SankeyGraph` import should occur before import of `./graphs/StackedBarGraph`

type ChooseGraphProps = {
data: DataEntity;
Expand Down Expand Up @@ -204,5 +205,21 @@
/>
);
}
if (graphType === 'SankeyGraph') {
return (
<SankeyGraph
style={graphStyle}
compact={compact}
graphData={data}
filters={filters}
groupBy={groupBy}
balanceTypeOp={balanceTypeOp}
viewLabels={viewLabels}
showHiddenCategories={showHiddenCategories}
showOffBudget={showOffBudget}
showTooltip={showTooltip}
/>
);
}
return null;
}
1 change: 1 addition & 0 deletions packages/desktop-client/src/components/reports/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function Header({
)
}
value={end}
defaultLabel={monthUtils.format(end, 'MMMM, yyyy')}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
style={{ marginRight: 10 }}
/>
Expand Down
20 changes: 20 additions & 0 deletions packages/desktop-client/src/components/reports/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
import { NetWorthCard } from './reports/NetWorthCard';
import { SpendingCard } from './reports/SpendingCard';
import './overview.scss';
import { SummaryCard } from './reports/SummaryCard';

Check warning on line 44 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { useFeatureFlag } from '../../hooks/useFeatureFlag';

Check warning on line 45 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups

Check warning on line 45 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

`../../hooks/useFeatureFlag` import should occur before import of `../../hooks/useNavigate`

Check warning on line 45 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

'useFeatureFlag' is defined but never used. Allowed unused vars must match /^(_|React)/u
import { SankeyCard } from './reports/SankeyCard';

Check warning on line 46 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

`./reports/SankeyCard` import should occur before import of `./reports/SpendingCard`

const ResponsiveGridLayout = WidthProvider(Responsive);

Expand Down Expand Up @@ -294,6 +296,7 @@
};

const accounts = useAccounts();
const enableSankey = false; //useFeatureFlag('sankeyChart');

if (isLoading) {
return <LoadingIndicator message={t('Loading reports...')} />;
Expand Down Expand Up @@ -364,7 +367,7 @@
return;
}

onAddWidget(item);

Check failure on line 370 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type '"net-worth-card" | "cash-flow-card" | "spending-card" | "summary-card" | "calendar-card" | "sankey-card"' is not assignable to parameter of type '"net-worth-card" | "cash-flow-card" | "spending-card" | "markdown-card" | "summary-card" | "calendar-card" | "custom-report"'.
}}
items={[
{
Expand All @@ -391,6 +394,14 @@
name: 'calendar-card' as const,
text: t('Calendar card'),
},
...(enableSankey
? [
{
name: 'sankey-card' as const,
text: t('Sankey card'),
},
]
: []),
{
name: 'custom-report' as const,
text: t('New custom report'),
Expand Down Expand Up @@ -549,6 +560,15 @@
onMetaChange={newMeta => onMetaChange(item, newMeta)}
onRemove={() => onRemoveWidget(item.i)}
/>
) : (enableSankey && item.type === 'sankey-card') ? (

Check failure on line 563 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `(enableSankey·&&·item.type·===·'sankey-card')` with `enableSankey·&&·item.type·===·'sankey-card'`

Check failure on line 563 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'type' does not exist on type 'never'.
<SankeyCard
widgetId={item.i}

Check failure on line 565 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'i' does not exist on type 'never'.
isEditing={isEditing}
meta={item.meta}

Check failure on line 567 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'meta' does not exist on type 'never'.
accounts={accounts}
onMetaChange={newMeta => onMetaChange(item, newMeta)}
onRemove={() => onRemoveWidget(item.i)}

Check failure on line 570 in packages/desktop-client/src/components/reports/Overview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'i' does not exist on type 'never'.
/>
) : null}
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { NetWorth } from './reports/NetWorth';
import { Spending } from './reports/Spending';
import { Summary } from './reports/Summary';
import { Sankey } from './reports/Sankey';

Check warning on line 11 in packages/desktop-client/src/components/reports/ReportRouter.tsx

View workflow job for this annotation

GitHub Actions / lint

`./reports/Sankey` import should occur before import of `./reports/Spending`

export function ReportRouter() {
return (
Expand All @@ -25,6 +26,8 @@
<Route path="/summary/:id" element={<Summary />} />
<Route path="/calendar" element={<Calendar />} />
<Route path="/calendar/:id" element={<Calendar />} />
<Route path="/sankey" element={<Sankey />} />
<Route path="/sankey/:id" element={<Sankey />} />
</Routes>
);
}
16 changes: 16 additions & 0 deletions packages/desktop-client/src/components/reports/ReportTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
SvgChart,
SvgChartBar,
SvgChartPie,
SvgChartSankey,
SvgListBullet,
SvgQueue,
SvgTag,
Expand All @@ -21,7 +22,8 @@

import { GraphButton } from './GraphButton';
import { SaveReport } from './SaveReport';
import { setSessionReport } from './setSessionReport';

Check warning on line 25 in packages/desktop-client/src/components/reports/ReportTopbar.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { useFeatureFlag } from '../../hooks/useFeatureFlag';

Check warning on line 26 in packages/desktop-client/src/components/reports/ReportTopbar.tsx

View workflow job for this annotation

GitHub Actions / lint

`../../hooks/useFeatureFlag` import should occur before import of `../../icons/v1`

type ReportTopbarProps = {
customReportItems: CustomReportEntity;
Expand Down Expand Up @@ -59,6 +61,7 @@
setGraphType(cond);
defaultItems(cond);
};
const enableSankey = useFeatureFlag('sankeyChart');

return (
<View
Expand Down Expand Up @@ -136,6 +139,19 @@
>
<SvgChartPie width={15} height={15} />
</GraphButton>
{ enableSankey ? (

Check failure on line 142 in packages/desktop-client/src/components/reports/ReportTopbar.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `·`
<GraphButton
title={t('Sankey Diagram')}
selected={customReportItems.graphType === 'SankeyGraph'}
onSelect={() => {
onChangeGraph('SankeyGraph');
}}
style={{ marginRight: 15 }}
disabled={isItemDisabled('ShowSankey')}
>
<SvgChartSankey width={15} height={15} />
</GraphButton>
) : null}
<View
style={{
width: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ const timeGraphOptions: graphOptions[] = [
disableLegend: false,
disableLabel: true,
},
{
description: 'SankeyGraph',
disabledSplit: ['Interval'],
defaultSplit: 'Category',
disabledType: [],
defaultType: 'Net',
},
];

const modeOptions = [
Expand All @@ -123,7 +130,7 @@ const modeOptions = [
{
description: 'time',
graphs: timeGraphOptions,
disabledGraph: ['AreaGraph', 'DonutGraph'],
disabledGraph: ['AreaGraph', 'DonutGraph', 'SankeyGraph'],
defaultGraph: 'TableGraph',
},
];
Expand Down
Loading
Loading