@hpcc-js/wasm-graphviz 1.24.1 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,6 +72,38 @@ const svg = graph.layout("svg", "dot");
72
72
  document.body.innerHTML = svg;
73
73
  ```
74
74
 
75
+ ### One-shot JSON init objects
76
+
77
+ You can also create graphs, clusters, nodes, and edges from a single object
78
+ that includes their attributes.
79
+
80
+ ```typescript
81
+ using graph = graphviz.createGraph({
82
+ name: "G",
83
+ type: "directed",
84
+ attrs: { rankdir: "LR" }
85
+ });
86
+
87
+ {
88
+ using cluster = graph.addSubgraph({
89
+ name: "cluster_0",
90
+ attrs: { label: "Group A", style: "filled", color: "lightgrey" }
91
+ });
92
+
93
+ cluster.addNode({
94
+ name: "a",
95
+ attrs: { shape: "box", color: "red" },
96
+ htmlAttrs: { label: "<B>A</B>" }
97
+ });
98
+
99
+ cluster.addEdge({
100
+ tail: "a",
101
+ head: "b",
102
+ attrs: { label: "hello" }
103
+ });
104
+ }
105
+ ```
106
+
75
107
  ```typescript
76
108
  using graph = graphviz.read(`digraph G { a -> b [label="hello"] }`);
77
109
  graph.setGraphAttr("rankdir", "LR");