documentation
This commit is contained in:
parent
e11f9bea68
commit
d478ccd955
32
README.md
32
README.md
@ -1,6 +1,6 @@
|
|||||||
# @sapphirecode/graphviz-builder
|
# @sapphirecode/graphviz-builder
|
||||||
|
|
||||||
version: 0.0.0
|
version: 1.1.x
|
||||||
|
|
||||||
constructing graphviz files using an easy typescript interface
|
constructing graphviz files using an easy typescript interface
|
||||||
|
|
||||||
@ -16,7 +16,35 @@ yarn:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
TODO: Add usage
|
### Object structure
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {Graph,Color} from '@sapphirecode/graphviz-builder';
|
||||||
|
|
||||||
|
// create a new graph
|
||||||
|
const g = new Graph('foo');
|
||||||
|
|
||||||
|
// add a node to the graph
|
||||||
|
// this function returns the full name of the node that's later used for creating edges
|
||||||
|
const bar = g.add_node('bar');
|
||||||
|
|
||||||
|
// if you want to specify attributes
|
||||||
|
const baz = g.add_node(n => {
|
||||||
|
n.name = 'baz';
|
||||||
|
n.label = 'node baz';
|
||||||
|
n.color = Color.red;
|
||||||
|
});
|
||||||
|
|
||||||
|
// connect nodes
|
||||||
|
g.add_edge(bar, baz);
|
||||||
|
|
||||||
|
// add a subgraph
|
||||||
|
g.add_graph(sg=>{
|
||||||
|
sg.name = 'subgraph';
|
||||||
|
|
||||||
|
sg.add_node('foo');
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user