Cross-platform interfaces for executing Graphviz DOT commands in various JavaScript runtimes.
🔗
It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
This library enables rendering DOT language strings into different output formats through platform-specific implementations for Node.js, and Deno.
Graphviz must be installed so that the dot command can be executed.
Execute the dot command to output a DOT language string to a stream or file.
The adapter provides two main functions for working with DOT language strings:
toStream
The toStream
function converts a DOT language string to a readable stream of the specified output format.
import { toStream } from '@ts-graphviz/adapter';
const dot = `
digraph example {
node1 [
label = "My Node",
]
}
`;
const stream = await toStream(dot, { format: 'svg' });
// Node.js
stream.pipe(process.stdout);
// Deno
await stream.pipeTo(Deno.stdout.writable);
toFile
The toFile
function writes the rendered output directly to a file at the specified path.
import { toFile } from '@ts-graphviz/adapter';
const dot = `
digraph example {
node1 [
label = "My Node",
]
}
`;
await toFile(dot, './result.svg', { format: 'svg' });
Both functions accept configuration options to customize the rendering process.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
See CHANGELOG.md for more details.
This software is released under the MIT License, see LICENSE.