DefinitelyTyped/types/graphviz/graphviz-tests.ts
Kamontat Chantrachirathumrong c4237728a1
[graphviz] Fix render options and try to remove any as much as possible (#45361)
* Update graphviz-tests.ts

* Update tslint.json

* Update index.d.ts

* union is unnecessary.

* Update index.d.ts

* add graphviz.org

* trigger build

* Update index.d.ts

* Update index.d.ts

* fix linter

* export everything and fix lint
2020-06-24 07:24:58 -04:00

27 lines
622 B
TypeScript

import graphviz = require("graphviz");
// Create digraph G
const g: graphviz.Graph = graphviz.digraph("G");
// Add node (ID: Hello)
const n1: graphviz.Node = g.addNode("Hello", { color: "blue" });
n1.set("style", "filled");
// Add node (ID: World)
g.addNode("World");
// Add edge between the two nodes
const e: graphviz.Edge = g.addEdge(n1, "World");
e.set("color", "red");
// Print the dot script
console.log(g.to_dot());
// Set GraphViz path (if not in your path)
g.setGraphVizPath("/usr/local/bin");
// Generate a PNG output
g.output("png", "test01.png");
g.output({ type: "pdf", use: "circo" }, "test02.pdf");