1 | ## Graphviz via `viz.js`
|
2 |
|
3 | Smartdown has integrated the powerful [viz.js](https://github.com/mdaines/viz.js) library, which is compiled into Javascript from the original Graphviz C code.
|
4 |
|
5 | Note: There is a similarly named package at [http://visjs.org](http://visjs.org) which Smartdown does not currently use.
|
6 |
|
7 | There is a Graphviz example displaying the `stdlib` namespaces at [Stdlib via Graphviz](:@Stdlib)
|
8 |
|
9 | ### Crazy.gv
|
10 |
|
11 | ```graphviz/playable
|
12 | digraph "unix" {
|
13 | graph [ fontname = "Helvetica-Oblique",
|
14 | fontsize = 36,
|
15 | label = "\n\n\n\nObject Oriented Graphs\nStephen North, 3/19/93",
|
16 | size = "12,12" ];
|
17 | node [ shape = polygon,
|
18 | sides = 4,
|
19 | distortion = "0.0",
|
20 | orientation = "0.0",
|
21 | skew = "0.0",
|
22 | color = white,
|
23 | style = filled,
|
24 | fontname = "Helvetica-Outline",
|
25 | fontsize = "36"];
|
26 | "5th Edition" [sides=9, distortion="0.936354", orientation=28, skew="-0.126818", color=salmon2];
|
27 | "6th Edition" [sides=5, distortion="0.238792", orientation=11, skew="0.995935", color=deepskyblue];
|
28 | "PWB 1.0" [sides=8, distortion="0.019636", orientation=79, skew="-0.440424", color=goldenrod2];
|
29 | LSX [sides=9, distortion="-0.698271", orientation=22, skew="-0.195492", color=burlywood2];
|
30 | "1 BSD" [sides=7, distortion="0.265084", orientation=26, skew="0.403659", color=gold1];
|
31 | "Mini Unix" [distortion="0.039386", orientation=2, skew="-0.461120", color=greenyellow];
|
32 | Wollongong [sides=5, distortion="0.228564", orientation=63, skew="-0.062846", color=darkseagreen];
|
33 | Interdata [distortion="0.624013", orientation=56, skew="0.101396", color=dodgerblue1];
|
34 | "Unix/TS 3.0" [sides=8, distortion="0.731383", orientation=43, skew="-0.824612", color=thistle2];
|
35 | "PWB 2.0" [sides=6, distortion="0.592100", orientation=34, skew="-0.719269", color=darkolivegreen3];
|
36 | "7th Edition" [sides=10, distortion="0.298417", orientation=65, skew="0.310367", color=chocolate];
|
37 | "8th Edition" [distortion="-0.997093", orientation=50, skew="-0.061117", color=turquoise3];
|
38 | "32V" [sides=7, distortion="0.878516", orientation=19, skew="0.592905", color=steelblue3];
|
39 | V7M [sides=10, distortion="-0.960249", orientation=32, skew="0.460424", color=navy];
|
40 | "Ultrix-11" [sides=10, distortion="-0.633186", orientation=10, skew="0.333125", color=darkseagreen4];
|
41 | Xenix [sides=8, distortion="-0.337997", orientation=52, skew="-0.760726", color=coral];
|
42 | "UniPlus+" [sides=7, distortion="0.788483", orientation=39, skew="-0.526284", color=darkolivegreen3];
|
43 | "9th Edition" [sides=7, distortion="0.138690", orientation=55, skew="0.554049", color=coral3];
|
44 | "2 BSD" [sides=7, distortion="-0.010661", orientation=84, skew="0.179249", color=blanchedalmond];
|
45 | "2.8 BSD" [distortion="-0.239422", orientation=44, skew="0.053841", color=lightskyblue1];
|
46 | "2.9 BSD" [distortion="-0.843381", orientation=70, skew="-0.601395", color=aquamarine2];
|
47 | "3 BSD" [sides=10, distortion="0.251820", orientation=18, skew="-0.530618", color=lemonchiffon];
|
48 | "4 BSD" [sides=5, distortion="-0.772300", orientation=24, skew="-0.028475", color=darkorange1];
|
49 | "4.1 BSD" [distortion="-0.226170", orientation=38, skew="0.504053", color=lightyellow1];
|
50 | "4.2 BSD" [sides=10, distortion="-0.807349", orientation=50, skew="-0.908842", color=darkorchid4];
|
51 | "4.3 BSD" [sides=10, distortion="-0.030619", orientation=76, skew="0.985021", color=lemonchiffon2];
|
52 | "Ultrix-32" [distortion="-0.644209", orientation=21, skew="0.307836", color=goldenrod3];
|
53 | "PWB 1.2" [sides=7, distortion="0.640971", orientation=84, skew="-0.768455", color=cyan];
|
54 | "USG 1.0" [distortion="0.758942", orientation=42, skew="0.039886", color=blue];
|
55 | "CB Unix 1" [sides=9, distortion="-0.348692", orientation=42, skew="0.767058", color=firebrick];
|
56 | "USG 2.0" [distortion="0.748625", orientation=74, skew="-0.647656", color=chartreuse4];
|
57 | "CB Unix 2" [sides=10, distortion="0.851818", orientation=32, skew="-0.020120", color=greenyellow];
|
58 | "CB Unix 3" [sides=10, distortion="0.992237", orientation=29, skew="0.256102", color=bisque4];
|
59 | "Unix/TS++" [sides=6, distortion="0.545461", orientation=16, skew="0.313589", color=mistyrose2];
|
60 | "PDP-11 Sys V" [sides=9, distortion="-0.267769", orientation=40, skew="0.271226", color=cadetblue1];
|
61 | "USG 3.0" [distortion="-0.848455", orientation=44, skew="0.267152", color=bisque2];
|
62 | "Unix/TS 1.0" [distortion="0.305594", orientation=75, skew="0.070516", color=orangered];
|
63 | "TS 4.0" [sides=10, distortion="-0.641701", orientation=50, skew="-0.952502", color=crimson];
|
64 | "System V.0" [sides=9, distortion="0.021556", orientation=26, skew="-0.729938", color=darkorange1];
|
65 | "System V.2" [sides=6, distortion="0.985153", orientation=33, skew="-0.399752", color=darkolivegreen4];
|
66 | "System V.3" [sides=7, distortion="-0.687574", orientation=58, skew="-0.180116", color=lightsteelblue1];
|
67 | "5th Edition" -> "6th Edition";
|
68 | "5th Edition" -> "PWB 1.0";
|
69 | "6th Edition" -> LSX;
|
70 | "6th Edition" -> "1 BSD";
|
71 | "6th Edition" -> "Mini Unix";
|
72 | "6th Edition" -> Wollongong;
|
73 | "6th Edition" -> Interdata;
|
74 | Interdata -> "Unix/TS 3.0";
|
75 | Interdata -> "PWB 2.0";
|
76 | Interdata -> "7th Edition";
|
77 | "7th Edition" -> "8th Edition";
|
78 | "7th Edition" -> "32V";
|
79 | "7th Edition" -> V7M;
|
80 | "7th Edition" -> "Ultrix-11";
|
81 | "7th Edition" -> Xenix;
|
82 | "7th Edition" -> "UniPlus+";
|
83 | V7M -> "Ultrix-11";
|
84 | "8th Edition" -> "9th Edition";
|
85 | "1 BSD" -> "2 BSD";
|
86 | "2 BSD" -> "2.8 BSD";
|
87 | "2.8 BSD" -> "Ultrix-11";
|
88 | "2.8 BSD" -> "2.9 BSD";
|
89 | "32V" -> "3 BSD";
|
90 | "3 BSD" -> "4 BSD";
|
91 | "4 BSD" -> "4.1 BSD";
|
92 | "4.1 BSD" -> "4.2 BSD";
|
93 | "4.1 BSD" -> "2.8 BSD";
|
94 | "4.1 BSD" -> "8th Edition";
|
95 | "4.2 BSD" -> "4.3 BSD";
|
96 | "4.2 BSD" -> "Ultrix-32";
|
97 | "PWB 1.0" -> "PWB 1.2";
|
98 | "PWB 1.0" -> "USG 1.0";
|
99 | "PWB 1.2" -> "PWB 2.0";
|
100 | "USG 1.0" -> "CB Unix 1";
|
101 | "USG 1.0" -> "USG 2.0";
|
102 | "CB Unix 1" -> "CB Unix 2";
|
103 | "CB Unix 2" -> "CB Unix 3";
|
104 | "CB Unix 3" -> "Unix/TS++";
|
105 | "CB Unix 3" -> "PDP-11 Sys V";
|
106 | "USG 2.0" -> "USG 3.0";
|
107 | "USG 3.0" -> "Unix/TS 3.0";
|
108 | "PWB 2.0" -> "Unix/TS 3.0";
|
109 | "Unix/TS 1.0" -> "Unix/TS 3.0";
|
110 | "Unix/TS 3.0" -> "TS 4.0";
|
111 | "Unix/TS++" -> "TS 4.0";
|
112 | "CB Unix 3" -> "TS 4.0";
|
113 | "TS 4.0" -> "System V.0";
|
114 | "System V.0" -> "System V.2";
|
115 | "System V.2" -> "System V.3";
|
116 | }
|
117 | ```
|
118 |
|
119 | ### Tree Example
|
120 |
|
121 | ```graphviz/autoplay/playable
|
122 | digraph L0 {
|
123 | size = "8,8";
|
124 | ordering=out;
|
125 | node [shape = box];
|
126 |
|
127 | n0 [label="E"];
|
128 | n1 [label="T"];
|
129 | n2 [label="F"];
|
130 | n3 [label="IDENT : a "];
|
131 | n4 [label="+"];
|
132 | n5 [label="T"];
|
133 | n6 [label="F"];
|
134 | n7 [label="("];
|
135 | n8 [label="E"];
|
136 | n9 [label="T"];
|
137 | n10 [label="F"];
|
138 | n11 [label="IDENT : b "];
|
139 | n12 [label="*"];
|
140 | n13 [label="F"];
|
141 | n14 [label="IDENT : c "];
|
142 | n15 [label=")"];
|
143 | n16 [label="*"];
|
144 | n17 [label="F"];
|
145 | n18 [label="("];
|
146 | n19 [label="E"];
|
147 | n20 [label="T"];
|
148 | n21 [label="F"];
|
149 | n22 [label="IDENT : d "];
|
150 | n23 [label="*"];
|
151 | n24 [label="F"];
|
152 | n25 [label="IDENT : e "];
|
153 | n26 [label="+"];
|
154 | n27 [label="T"];
|
155 | n28 [label="F"];
|
156 | n29 [label="("];
|
157 | n30 [label="E"];
|
158 | n31 [label="T"];
|
159 | n32 [label="F"];
|
160 | n33 [label="IDENT : a "];
|
161 | n34 [label="*"];
|
162 | n35 [label="F"];
|
163 | n36 [label="IDENT : b "];
|
164 | n37 [label=")"];
|
165 | n38 [label=")"];
|
166 | n39 [label="+"];
|
167 | n40 [label="T"];
|
168 | n41 [label="F"];
|
169 | n42 [label="IDENT : q "];
|
170 | n0 -> { n1 n4 n5 n39 n40 };
|
171 | n1 -> n2 ;
|
172 | n2 -> n3 ;
|
173 | n5 -> { n6 n16 n17 };
|
174 | n6 -> { n7 n8 n15 };
|
175 | n8 -> n9 ;
|
176 | n9 -> { n10 n12 n13 };
|
177 | n10 -> n11 ;
|
178 | n13 -> n14 ;
|
179 | n17 -> { n18 n19 n38 };
|
180 | n19 -> { n20 n26 n27 };
|
181 | n20 -> { n21 n23 n24 };
|
182 | n21 -> n22 ;
|
183 | n24 -> n25 ;
|
184 | n27 -> n28 ;
|
185 | n28 -> { n29 n30 n37 };
|
186 | n30 -> n31 ;
|
187 | n31 -> { n32 n34 n35 };
|
188 | n32 -> n33 ;
|
189 | n35 -> n36 ;
|
190 | n40 -> n41 ;
|
191 | n41 -> n42 ;
|
192 | }
|
193 | ```
|
194 |
|
195 | ### Using Images
|
196 |
|
197 | This needs better documentation. It is an early-stage feature still under development.
|
198 |
|
199 | When Smartdown is initialized via `smartdown.initialize`, it is provided with a list of images that can be used with the SVG `/media` syntax (see [SVG](:@SVG) for more info). This same set of images is also made available to Graphviz via its `image:` attribute to nodes.
|
200 |
|
201 | ```graphviz/playable/autoplay
|
202 | digraph diagram {
|
203 | compound=true;
|
204 | ranksep=1
|
205 | node[shape=record]
|
206 |
|
207 | subgraph cluster_all {
|
208 | label="Web Host, Content, Author and Reader"
|
209 |
|
210 | firewall2 [shape=none, label="firewall2", labelloc="b", image="/resources/lighthouse.svg"]
|
211 | firewall1 [shape=none, label="firewall1", labelloc="b", image="/resources/cloud.jpg"]
|
212 |
|
213 | Author [shape=none, label="Author DrBud", image="/resources/cloud.jpg"]
|
214 | ContentABC [shape=tab, label="Content/ABC"]
|
215 | WebABC [shape=tab, label="Website/ABC"]
|
216 | Author -> ContentABC
|
217 | ContentABC -> WebABC
|
218 | }
|
219 | }
|
220 | ```
|
221 |
|
222 | ---
|
223 |
|
224 | [Back to Home](:@Home)
|
225 |
|