Skip to content

Commit 1534521

Browse files
committed
directed graph with viewGenerator
1 parent 0ac8c47 commit 1534521

File tree

11 files changed

+535
-288
lines changed

11 files changed

+535
-288
lines changed

Diff for: sandbox/data/custom-node/custom-node.config.js

+42-42
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@ import React from "react";
22
import CustomNode from "./CustomNode";
33

44
export default {
5-
automaticRearrangeAfterDropNode: false,
6-
collapsible: false,
7-
height: 400,
8-
highlightDegree: 1,
9-
highlightOpacity: 0.2,
10-
linkHighlightBehavior: true,
11-
maxZoom: 8,
12-
minZoom: 0.1,
13-
nodeHighlightBehavior: true,
14-
panAndZoom: false,
15-
staticGraph: false,
16-
width: 800,
17-
node: {
18-
color: "#d3d3d3",
19-
fontColor: "black",
20-
fontSize: 12,
21-
fontWeight: "normal",
22-
highlightColor: "red",
23-
highlightFontSize: 12,
24-
highlightFontWeight: "bold",
25-
highlightStrokeColor: "SAME",
26-
highlightStrokeWidth: 1.5,
27-
labelProperty: "name",
28-
mouseCursor: "pointer",
29-
opacity: 1,
30-
renderLabel: false,
31-
size: {
32-
width: 700,
33-
height: 900,
34-
},
35-
strokeColor: "none",
36-
strokeWidth: 1.5,
37-
svg: "",
38-
symbolType: "circle",
39-
viewGenerator: node => <CustomNode person={node} />,
40-
},
41-
link: {
42-
color: "#d3d3d3",
43-
opacity: 1,
44-
semanticStrokeWidth: false,
45-
strokeWidth: 4,
46-
highlightColor: "blue",
5+
automaticRearrangeAfterDropNode: false,
6+
collapsible: false,
7+
height: 400,
8+
highlightDegree: 1,
9+
highlightOpacity: 0.2,
10+
linkHighlightBehavior: true,
11+
maxZoom: 8,
12+
minZoom: 0.1,
13+
nodeHighlightBehavior: true,
14+
panAndZoom: false,
15+
staticGraph: false,
16+
width: 800,
17+
directed: true,
18+
node: {
19+
color: "#d3d3d3",
20+
fontColor: "black",
21+
fontSize: 12,
22+
fontWeight: "normal",
23+
highlightColor: "red",
24+
highlightFontSize: 12,
25+
highlightFontWeight: "bold",
26+
highlightStrokeColor: "SAME",
27+
highlightStrokeWidth: 1.5,
28+
labelProperty: "name",
29+
mouseCursor: "pointer",
30+
opacity: 1,
31+
renderLabel: false,
32+
size: {
33+
width: 700,
34+
height: 900,
4735
},
36+
strokeColor: "none",
37+
strokeWidth: 1.5,
38+
svg: "",
39+
viewGenerator: node => <CustomNode person={node} />,
40+
},
41+
link: {
42+
color: "#d3d3d3",
43+
opacity: 1,
44+
semanticStrokeWidth: false,
45+
strokeWidth: 4,
46+
highlightColor: "blue",
47+
},
4848
};

Diff for: src/components/graph/graph.builder.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CONST from "./graph.const";
77

88
import { buildLinkPathDefinition } from "../link/link.helper";
99
import { getMarkerId } from "../marker/marker.helper";
10-
import { getNormalizedNodeCoordinates } from "./graph.helper";
10+
import { getNormalizedNodeCoordinates } from "./graph.coords";
1111

1212
/**
1313
* Get the correct node opacity in order to properly make decisions based on context such as currently highlighted node.
@@ -129,7 +129,8 @@ function buildLinkProps(link, nodes, links, config, linkCallbacks, highlightedNo
129129
{ sourceId: source, targetId: target, sourceCoords: { x: x1, y: y1 }, targetCoords: { x: x2, y: y2 } },
130130
nodes,
131131
config,
132-
strokeWidth
132+
strokeWidth,
133+
link.breakPoints
133134
);
134135

135136
const d = buildLinkPathDefinition(sourceCoords, targetCoords, type, link.breakPoints);

Diff for: src/components/graph/graph.const.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ export default {
1212
LINK_CLASS_NAME: "link",
1313
NODE_CLASS_NAME: "node",
1414
TTL_DOUBLE_CLICK_IN_MS: 300,
15+
SYMBOLS_WITH_OPTIMIZED_POSITIONING: new Set([CONST.SYMBOLS.CIRCLE, CONST.SYMBOLS.SQUARE]),
1516
...CONST,
1617
};

0 commit comments

Comments
 (0)