- Automatically generate graph images using
mxGraphrunning in a host container usingstatic-serverand headless browser automation withpuppeteer. - Automatically generate
drawiographs using the abovemxGraphXML
Conceptually
- Input: Javascript
mxGraphbuilder (e.g../people-process-technology.js) - Output:
- Graph as
.pngimage - Graph as
.drawiofile
- Graph as
- Execute the NodeJS script
- Initiates the custom graph library
- Starts
static-serverathttp://localhost:8080pointed to./lib/index.htmlcontaining themxGraphjavascript files and a<div>container to render the graph - Starts a headless chromium browser with
puppeteerpointed tohttp://localhost:8080 - Injects a custom graph script (e.g.
./people-process-technology.js) into the HTML page using Puppeteer APIs - Configures the
mxGraphjavascript 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 themxGraphAPIs and any extensions fordraw.io. - Exports the
mxGraphXML - Generates a screenshot of the graph using
puppeteerand exports the image in.pngformat - Encodes the
mxGraphXML intodraw.ioformat and generates a.drawiofile - Uses
puppeteerto close the headless Chromium browser and stops thestatic-serverweb 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.

