Skip to content

Commit adccd37

Browse files
authored
Forcing value to 1 on SANKEY_UNWEIGHTED (#419)
1 parent ccffa60 commit adccd37

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/modules/ROOT/pages/user-guide/reports/sankey.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ the visualization.
3131
user hovers over a node or link.
3232

3333
|Relationship Property |text | value | Name of the property with an integer value that is going
34-
to be used to determine thickness of links.
34+
to be used to determine thickness of links. Using 'SANKEY_UNWEIGHTED', this sankey will assume
35+
every relationship with a weight of 1.
3536

3637
|Color Scheme |List | |The color scheme to use for the slices. Colors
3738
are assigned automatically (consecutively) to the different categories

src/extensions/advancedcharts/chart/sankey/SankeyChart.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import NeoCodeViewerComponent from '../../../../component/editor/CodeViewerCompo
88
import { isCyclic } from '../../Utils';
99
import { extensionEnabled } from '../../../ExtensionUtils';
1010

11+
const UNWEIGHTED_SANKEY_PROPERTY = 'SANKEY_UNWEIGHTED';
12+
1113
/**
1214
* Embeds a SankeyChart (from Charts) into NeoDash.
1315
*/
@@ -74,7 +76,16 @@ const NeoSankeyChart = (props: ChartProps) => {
7476
links[`${value.start.low},${value.end.low}`] = [];
7577
}
7678
const addItem = (arr, item) => arr.find((x) => x.id === item.id) || arr.push(item);
77-
if (value.properties[labelProperty] !== undefined && !isNaN(value.properties[labelProperty])) {
79+
if (labelProperty === UNWEIGHTED_SANKEY_PROPERTY) {
80+
addItem(links[`${value.start.low},${value.end.low}`], {
81+
id: value.identity.low,
82+
source: value.start.low,
83+
target: value.end.low,
84+
type: value.type,
85+
properties: value.properties,
86+
value: 1,
87+
});
88+
} else if (value.properties[labelProperty] !== undefined && !isNaN(value.properties[labelProperty])) {
7889
addItem(links[`${value.start.low},${value.end.low}`], {
7990
id: value.identity.low,
8091
source: value.start.low,

0 commit comments

Comments
 (0)