https://github.com/rsms/graphviz
Graphviz web app
https://github.com/rsms/graphviz
Last synced: 7 months ago
JSON representation
Graphviz web app
- Host: GitHub
- URL: https://github.com/rsms/graphviz
- Owner: rsms
- License: mit
- Created: 2019-10-31T22:17:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T18:27:40.000Z (about 3 years ago)
- Last Synced: 2025-06-13T05:48:06.721Z (7 months ago)
- Language: JavaScript
- Homepage: https://rsms.me/graphviz/
- Size: 631 KB
- Stars: 125
- Watchers: 4
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - graphviz
README
# Graphviz in the browser
Provides a very small JS library
- Exposes a global variable `graphvis`
- Very fast
- Runs graphviz compiled as WebAssembly in a background Worker thread
- Timeouts for preventing run-away "huge graph" computations
## Usage
```html
graphviz.layout(`
digraph {
Hello -> World
Hej -> Hello
Värld -> World -> Hej
}
`).then(svg => {
document.body.innerHTML = svg
})
```
## API
```ts
namespace graphviz {
// Version string of this library (e.g. "1.2.3")
export const version :string
// Error raised on timeout
export const TimeoutError :Error
// layout performs Graphviz layout
export function layout(
source :string, // dot source code
format? :Format, // Output format. Defaults to "svg"
engine? :Engine, // Default engine type. Defaults to "dot"
timeout? :number, // Optional timeout in milliseconds
) :Promise
// Output formats
export type Format = "dot"
| "json"
| "json0"
| "plain"
| "plain-ext"
| "ps"
| "ps2"
| "svg"
| "xdot"
// Layout engine types
export type Engine = "circo" // for circular layout of graphs
| "dot" // for drawing directed graphs
| "fdp" // for drawing undirected graphs
| "neato" // for drawing undirected graphs
| "osage" // for drawing large undirected graphs
| "twopi" // for radial layouts of graphs
}
```
## Notes
This is essentially a wrapper around [viz.js](https://github.com/mdaines/viz.js).
See [Graphviz documentation here](https://www.graphviz.org/doc/info/attrs.html)