- Automatically generate graph images using
mxGraph
running in a host container usingstatic-server
and headless browser automation withpuppeteer
. - Automatically generate
drawio
graphs using the abovemxGraph
XML
Conceptually
- Input: Javascript
mxGraph
builder (e.g../people-process-technology.js
) - Output:
- Graph as
.png
image - Graph as
.drawio
file
- Graph as
- Execute the NodeJS script
- Initiates the custom graph library
- Starts
static-server
athttp://localhost:8080
pointed to./lib/index.html
containing themxGraph
javascript files and a<div>
container to render the graph - Starts a headless chromium browser with
puppeteer
pointed tohttp://localhost:8080
- Injects a custom graph script (e.g.
./people-process-technology.js
) into the HTML page using Puppeteer APIs - Configures the
mxGraph
javascript object for updates - Executes a standard function
buildGraph(graph)
expected to reside in the custom graph script (e.g../people-process-technology.js
). This function should create the custom graph using themxGraph
APIs and any extensions fordraw.io
. - Exports the
mxGraph
XML - Generates a screenshot of the graph using
puppeteer
and exports the image in.png
format - Encodes the
mxGraph
XML intodraw.io
format and generates a.drawio
file - Uses
puppeteer
to close the headless Chromium browser and stops thestatic-server
web server
Technical Prerequisites
- Install NodeJS
- Install a git client
- Clone or download this project
Steps
- Install library dependencies with
npm i
- Execute the node script
build
(e.g.npm run build
) - Execute the node script
build:ppt
(e.g.npm run build:ppt
)
This example demonstrates the use of custom styles, support for draw.io links with the use of UserObject
, and ensures edges are below vertices (shapes). View the clickable diagram on draw.io.
This example demonstrates basic, connected shapes. View the generated diagram on draw.io.