diff --git a/frontend/app/components/Charts/SankeyChart.tsx b/frontend/app/components/Charts/SankeyChart.tsx index 9f2ca31c4..4142e395e 100644 --- a/frontend/app/components/Charts/SankeyChart.tsx +++ b/frontend/app/components/Charts/SankeyChart.tsx @@ -34,11 +34,12 @@ interface Props { onChartClick?: (filters: any[]) => void; isUngrouped?: boolean; inGrid?: boolean; + startPoint: 'end' | 'start' } const EChartsSankey: React.FC = (props) => { const { t } = useTranslation(); - const { data, height = 240, onChartClick, isUngrouped } = props; + const { data, height = 240, onChartClick, isUngrouped, startPoint } = props; const chartRef = React.useRef(null); const [finalNodeCount, setFinalNodeCount] = React.useState(data.nodes.length); @@ -110,8 +111,9 @@ const EChartsSankey: React.FC = (props) => { if (echartNodes.length === 0) return; + const mainNodeLink = startPoint === 'end' ? echartNodes.findIndex(n => n.id === 0) : 0; const startNodeValue = echartLinks - .filter((link) => link.source === 0) + .filter((link) => startPoint === 'start' ? link.source === mainNodeLink : link.target === mainNodeLink) .reduce((sum, link) => sum + link.value, 0); Object.keys(nodeValues).forEach((nodeId) => { diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 4b0313ef2..0460053a5 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -538,6 +538,7 @@ function WidgetChart(props: Props) { dashboardStore.drillDownFilter.merge({ filters, page: 1 }); }} isUngrouped={isUngrouped} + startPoint={metric.startType} /> ); }