@neo4j-nvl/react
Advanced tools
@@ -26,2 +26,4 @@ import type { ExternalCallbacks, Layout, LayoutOptions, Node, NvlOptions, Relationship } from '@neo4j-nvl/base'; | ||
nvlOptions?: NvlOptions; | ||
/** Sets the positions of the nodes in the graph using the {@link NVL.setNodePositions} method. */ | ||
positions?: Node[]; | ||
/** A callback to handle any errors that happen during NVL initialization */ | ||
@@ -28,0 +30,0 @@ onInitializationError?: (error: unknown) => void; |
@@ -15,3 +15,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
*/ | ||
export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions = {}, onInitializationError, ...nvlEvents }, ref) => { | ||
export const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions = {}, positions = [], onInitializationError, ...nvlEvents }, ref) => { | ||
const nvlRef = useRef(null); | ||
@@ -111,3 +111,9 @@ useImperativeHandle(ref, () => { | ||
}, [nvlOptions.disableWebGL]); | ||
useEffect(() => { | ||
if (nvlRef.current === null || positions.length === 0) { | ||
return; | ||
} | ||
nvlRef.current.setNodePositions(positions); | ||
}, [positions]); | ||
return _jsx("div", { id: BASIC_WRAPPER_ID, ref: containerRef, style: { height: '100%', outline: '0' }, ...nvlEvents }); | ||
})); |
{ | ||
"name": "@neo4j-nvl/react", | ||
"version": "0.3.6-d168b648", | ||
"version": "0.3.6-d3c1707d", | ||
"main": "lib/index.js", | ||
@@ -37,4 +37,4 @@ "homepage": "https://neo4j.com/docs/nvl/current/", | ||
"dependencies": { | ||
"@neo4j-nvl/base": "0.3.6-d168b648", | ||
"@neo4j-nvl/interaction-handlers": "0.3.6-d168b648", | ||
"@neo4j-nvl/base": "0.3.6-d3c1707d", | ||
"@neo4j-nvl/interaction-handlers": "0.3.6-d3c1707d", | ||
"lodash": "4.17.21", | ||
@@ -41,0 +41,0 @@ "react": "^18.2.0", |
60624
0.55%560
1.45%