From 25b799a77370589dc733ce360c4b538a20cc3b69 Mon Sep 17 00:00:00 2001 From: shaan Date: Tue, 24 Oct 2023 00:13:06 +0000 Subject: [PATCH] add tooltip names...again --- .../components/reports/graphs/SankeyGraph.tsx | 76 +++++++++++-------- .../reports/graphs/sankey-spreadsheet.tsx | 1 + 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx index a07d26934c0..b246cf00b2c 100644 --- a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx +++ b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx @@ -8,6 +8,8 @@ import { ResponsiveContainer, } from 'recharts'; +import Container from '../Container'; + type SankeyProps = { style; data; @@ -22,9 +24,8 @@ const numberFormatterTooltip = (value: PotentialNumber): number | null => { return null; // or some default value for other cases }; -function SankeyNode({ x, y, width, height, index, payload }) { - // const isOut = x + width + 6 > containerWidth; - const isOut = false; // not configured yet +function SankeyNode({ x, y, width, height, index, payload, containerWidth }) { + const isOut = x + width + 6 > containerWidth; let payloadValue = Math.round(payload.value / 1000).toString(); if (payload.value < 1000) { payloadValue = '<1k'; @@ -89,36 +90,45 @@ function SankeyGraph({ style, data, compact }: SankeyProps) { if (!data.links || data.links.length === 0) return null; return ( - - } - sort={false} - iterations={1000} - nodePadding={23} - margin={ - compact - ? { - left: 0, - right: 0, - top: 0, - bottom: 0, - } - : { - left: 0, - right: 0, - top: 10, - bottom: 25, - } - } - > - - - + + {(width, height, portalHost) => ( + + } + sort={true} + iterations={1000} + nodePadding={23} + margin={ + compact + ? { + left: 0, + right: 0, + top: 0, + bottom: 0, + } + : { + left: 0, + right: 0, + top: 10, + bottom: 25, + } + } + > + + + + )} + ); } diff --git a/packages/desktop-client/src/components/reports/graphs/sankey-spreadsheet.tsx b/packages/desktop-client/src/components/reports/graphs/sankey-spreadsheet.tsx index 8a098716069..7946aff2a50 100644 --- a/packages/desktop-client/src/components/reports/graphs/sankey-spreadsheet.tsx +++ b/packages/desktop-client/src/components/reports/graphs/sankey-spreadsheet.tsx @@ -165,6 +165,7 @@ function transformToSankeyData(categoryData, incomeData) { value: integerToAmount(mainCategorySum), }); + // add the subcategories of the main category for (let subCategory of mainCategory.balances) { if (!nodeNames.has(subCategory.subcategory) && subCategory.value > 0) { data.nodes.push({ name: subCategory.subcategory });