balibabu
commited on
Commit
·
7bcfa53
1
Parent(s):
8a4f6c9
feat: Increase the distance between nodes #162 (#1758)
Browse files### What problem does this PR solve?
feat: Increase the distance between nodes #162
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/pages/force-graph/index.tsx
CHANGED
@@ -19,12 +19,22 @@ const finalData = { ...graphData, ...nextData };
|
|
19 |
const ForceGraph = () => {
|
20 |
const containerRef = useRef<HTMLDivElement>(null);
|
21 |
const size = useSize(containerRef);
|
|
|
22 |
|
23 |
const render = () => {
|
24 |
-
|
25 |
container: containerRef.current!,
|
26 |
autoFit: 'view',
|
27 |
-
behaviors: [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
plugins: [
|
29 |
{
|
30 |
type: 'tooltip',
|
@@ -44,20 +54,34 @@ const ForceGraph = () => {
|
|
44 |
],
|
45 |
layout: {
|
46 |
type: 'combo-combined',
|
47 |
-
|
|
|
|
|
48 |
},
|
49 |
node: {
|
50 |
style: {
|
51 |
size: 20,
|
52 |
labelText: (d) => d.id,
|
53 |
-
labelPadding:
|
54 |
// labelOffsetX: 20,
|
55 |
-
labelOffsetY: 5,
|
|
|
|
|
56 |
},
|
57 |
palette: {
|
58 |
type: 'group',
|
59 |
field: (d) => d.combo,
|
60 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
},
|
62 |
edge: {
|
63 |
style: (model) => {
|
@@ -77,6 +101,7 @@ const ForceGraph = () => {
|
|
77 |
};
|
78 |
|
79 |
useEffect(() => {
|
|
|
80 |
render();
|
81 |
}, []);
|
82 |
|
|
|
19 |
const ForceGraph = () => {
|
20 |
const containerRef = useRef<HTMLDivElement>(null);
|
21 |
const size = useSize(containerRef);
|
22 |
+
let graph: Graph;
|
23 |
|
24 |
const render = () => {
|
25 |
+
graph = new Graph({
|
26 |
container: containerRef.current!,
|
27 |
autoFit: 'view',
|
28 |
+
behaviors: [
|
29 |
+
'drag-element',
|
30 |
+
'drag-canvas',
|
31 |
+
'zoom-canvas',
|
32 |
+
'collapse-expand',
|
33 |
+
{
|
34 |
+
type: 'hover-activate',
|
35 |
+
degree: 1, // 👈🏻 Activate relations.
|
36 |
+
},
|
37 |
+
],
|
38 |
plugins: [
|
39 |
{
|
40 |
type: 'tooltip',
|
|
|
54 |
],
|
55 |
layout: {
|
56 |
type: 'combo-combined',
|
57 |
+
preventOverlap: true,
|
58 |
+
comboPadding: 1,
|
59 |
+
spacing: 20,
|
60 |
},
|
61 |
node: {
|
62 |
style: {
|
63 |
size: 20,
|
64 |
labelText: (d) => d.id,
|
65 |
+
labelPadding: 30,
|
66 |
// labelOffsetX: 20,
|
67 |
+
// labelOffsetY: 5,
|
68 |
+
labelPlacement: 'center',
|
69 |
+
labelWordWrap: true,
|
70 |
},
|
71 |
palette: {
|
72 |
type: 'group',
|
73 |
field: (d) => d.combo,
|
74 |
},
|
75 |
+
// state: {
|
76 |
+
// highlight: {
|
77 |
+
// fill: '#D580FF',
|
78 |
+
// halo: true,
|
79 |
+
// lineWidth: 0,
|
80 |
+
// },
|
81 |
+
// dim: {
|
82 |
+
// fill: '#99ADD1',
|
83 |
+
// },
|
84 |
+
// },
|
85 |
},
|
86 |
edge: {
|
87 |
style: (model) => {
|
|
|
101 |
};
|
102 |
|
103 |
useEffect(() => {
|
104 |
+
console.info('rendered');
|
105 |
render();
|
106 |
}, []);
|
107 |
|