NodeJS Demo
This demo shows how to run a yFiles layout algorithm in a
Node.js®
environment. This makes it possible to run the layout calculation asynchronously,
preventing it from blocking the UI.
To transfer the graph structure and layout between the Node.js
Express server and the main
page, the LayoutExecutorAsync creates a serializable data object on the
client-side and sends it to the Node.js server.
On the server-side, the LayoutExecutorAsyncWorker parses this data object
and provides a callback which allows to apply a layout on the parsed graph. This callback
is executed by calling process(data) on the worker which resolves with a
serializable result data object that is supposed to be sent back to the
LayoutExecutorAsync.
On the client-side, the LayoutExecutorAsync waits for the response of the
LayoutExecutorAsyncWorker
and eventually applies the result to the graph.
Things to Try
Modify the graph structure by adding/removing nodes and edges, and re-run the
Node.js layout.
Running the Node.js Layout Server
- Navigate to the
server subdirectory of this demo's directory
-
Install the required node modules:
> npm install
-
Run the layout server:
> npm start