https://github.com/fabiospampinato/graphviz-wasm
A port of Graphviz to WASM.
https://github.com/fabiospampinato/graphviz-wasm
dot graphviz wasm
Last synced: 9 months ago
JSON representation
A port of Graphviz to WASM.
- Host: GitHub
- URL: https://github.com/fabiospampinato/graphviz-wasm
- Owner: fabiospampinato
- License: mit
- Created: 2021-12-27T17:45:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-05T00:07:07.000Z (about 2 years ago)
- Last Synced: 2024-09-20T00:13:50.484Z (almost 2 years ago)
- Topics: dot, graphviz, wasm
- Language: TypeScript
- Homepage:
- Size: 951 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Graphviz WASM
A port of Graphviz to WASM.
Note: this is currently just a light wrapper around [`@hpcc-js/wasm`](https://www.npmjs.com/package/@hpcc-js/wasm), you might want to consider just using that directly. The plan is to eventually generate custom bindings to graphviz, optimized for speed and size, and depending on your use case you'd import the right one.
## Install
```sh
npm install --save graphviz-wasm
```
## Usage
This is how you'd use the library:
```ts
import graphviz from 'graphviz-wasm';
await graphviz.loadWASM (); // First of all you need to load the WASM instance and wait for it
const dot = `
strict graph {
a -- b
a -- b
b -- a [color=blue]
}
`;
const svg = graphviz.layout ( dot );
```
This is the interface of the `layout` method:
```ts
type Engine = 'circo' | 'dot' | 'fdp' | 'neato' | 'osage' | 'patchwork' | 'sfdp' | 'twopi';
type Format = 'dot_json' | 'dot' | 'json' | 'plain-ext' | 'plain' | 'svg' | 'xdot_json';
type layout = ( source: string, format: Format = 'svg', engine: Engine = 'dot' ) => string;
```
## License
- **Graphviz**: EPL © [Graphviz](https://gitlab.com/graphviz/graphviz/-/blob/main/LICENSE).
- **WASM Port**: Apache © [hpcc-js-wasm](https://github.com/hpcc-systems/hpcc-js-wasm/blob/trunk/LICENSE).
- **Rest**: MIT © Fabio Spampinato.