@neo4j-nvl/layout-workers 0.2.12 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { layout } from './cose-bilkent-layout-impl.js';
|
|
2
2
|
const onMessage = ({ data, target }) => {
|
|
3
3
|
if (target.name === 'CoseBilkentLayout') {
|
|
4
|
-
const { elements,
|
|
5
|
-
const layoutData = layout(elements,
|
|
4
|
+
const { elements, spacingFactor } = data;
|
|
5
|
+
const layoutData = layout(elements, spacingFactor);
|
|
6
6
|
postMessage(layoutData);
|
|
7
7
|
}
|
|
8
8
|
};
|
|
@@ -2,11 +2,10 @@ import cytoscape from 'cytoscape';
|
|
|
2
2
|
import coseBilkent from 'cytoscape-cose-bilkent';
|
|
3
3
|
cytoscape.use(coseBilkent);
|
|
4
4
|
const type = 'cose-bilkent';
|
|
5
|
-
export const layout = (elements,
|
|
5
|
+
export const layout = (elements, spacingFactor) => {
|
|
6
6
|
const c = cytoscape({
|
|
7
7
|
headless: true,
|
|
8
|
-
styleEnabled: false
|
|
9
|
-
boundingBox
|
|
8
|
+
styleEnabled: false
|
|
10
9
|
});
|
|
11
10
|
c.add(elements);
|
|
12
11
|
const positions = {};
|
|
@@ -20,8 +19,6 @@ export const layout = (elements, boundingBox, spacingFactor, nodeCenterPoint) =>
|
|
|
20
19
|
stop: () => {
|
|
21
20
|
c.nodes().forEach((n) => {
|
|
22
21
|
positions[n.id()] = { ...n.position() };
|
|
23
|
-
positions[n.id()].x += nodeCenterPoint[0];
|
|
24
|
-
positions[n.id()].y += nodeCenterPoint[1];
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
});
|