Skip to content

Commit 66b42b7

Browse files
authored
Cycle detection (#206)
* Cycle detection * Moving deps
1 parent d842efe commit 66b42b7

File tree

2 files changed

+55
-328
lines changed

2 files changed

+55
-328
lines changed

src/chart/visualizations/SankeyVisualization.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
1+
import React, { useEffect } from 'react';
22
import { ResponsiveSankey } from '@nivo/sankey'
33
import { ChartReportProps, ExtendedChartReportProps } from './VisualizationProps'
44
import {evaluateRulesOnDict, evaluateRulesOnNode} from '../../report/ReportRuleEvaluator'
55
import {categoricalColorSchemes} from "../../config/ColorConfig";
66
import {valueIsArray, valueIsNode, valueIsPath, valueIsRelationship} from "../../report/ReportRecordProcessing";
77
import NeoCodeViewerComponent from '../../component/editor/CodeViewerComponent';
8+
import {isCyclic} from '../visualizations/Utils';
89

910
export default function SankeyVisualization(props: ExtendedChartReportProps) {
1011
const { records, first } = props
@@ -147,7 +148,7 @@ export default function SankeyVisualization(props: ExtendedChartReportProps) {
147148
break;
148149
default:
149150
lbl = item.properties[props.selection[item.lastLabel]];
150-
};
151+
}
151152

152153
return typeof lbl === 'object' ? lbl["low"] : lbl;
153154
}
@@ -156,7 +157,12 @@ export default function SankeyVisualization(props: ExtendedChartReportProps) {
156157
return <NeoCodeViewerComponent value={"No relationship weights found. \nDefine a numeric 'Relationship Property' in the \nreport's advanced settings to view the sankey diagram."}></NeoCodeViewerComponent>
157158
}
158159

159-
return <ResponsiveSankey
160+
161+
if(data && data.nodes && data.links && isCyclic(data)){
162+
return <NeoCodeViewerComponent value={"Please be careful with the data you use for this chart as it does not support cyclic dependencies."}></NeoCodeViewerComponent>;
163+
}
164+
165+
return <ResponsiveSankey
160166
data={data}
161167
margin={{ top: marginTop, right: (legend) ? legendWidth + marginRight : marginRight, bottom: (legend) ? legendHeight + marginBottom : marginBottom, left: marginLeft }}
162168
isInteractive={interactive}

0 commit comments

Comments
 (0)