This project is a Makefile for building Graphviz with Emscripten and a simple wrapper for using it in the browser.
Install with Bower:
bower install viz.js
Or, download the viz.js
"binary" from the releases page.
There is one function, Viz
, which returns output as a string.
Viz(src, options={ format="svg", engine="dot" })
Some examples:
result = Viz("digraph g { a -> b; }");
result = Viz("graph G { n0 -- n1 -- n2 -- n3 -- n0; }", { engine: "neato" });
result = Viz("digraph g { x -> y -> z; }", { format: "plain" });
If src
has a syntax error, Graphviz's error message will be thrown as an exception.
These engines are supported:
- circo
- dot
- fdp
- neato
- osage
- twopi
These formats are supported:
- svg
- xdot
- plain
- ps
To build from source, you will need to install the Emscripten SDK: http://kripken.github.io/emscripten-site/docs/getting_started/index.html
To download the sources and build everything:
make
Viz.js itself (the Makefile and the contents of src/) is BSD licensed.