You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add 'color', 'width' and 'fill' attributes to GraphViz and D2 graphs (#2569)
* Add 'color', 'width' and 'fill' to shared attributes, so D2 graphs
can use the 'graph' values
* Map the well-known graph attributes to Graph Language (GL)-
specific node/edge attributes (D2 and GraphViz)
* Use the 'style_map' graph settings to map well-known attributes to
GL-specific attributes, giving the users infinite extensibility.
* Add support for GraphViz node and edge formatting attributes
Copy file name to clipboardExpand all lines: docs/outputs/d2.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ A single formatting modifier can be used to specify the graph type:
11
11
***bgp** -- Include autonomous systems, nodes, and BGP sessions. With the **rr** option (specified with `netlab create -o graph:bgp:rr`), RR-client sessions are drawn as directed arrows.
12
12
13
13
```{tip}
14
-
The network topology graph description contains nodes and links, but no placement information. D2 is pretty good at figuring out how to draw the required graph, but it pays off to test out the [layout engines](https://d2lang.com/tour/layouts). Changing the [order of links](outputs-d2-style-attributes) might also unclutter the diagrams.
14
+
The network topology graph description contains nodes and links, but no placement information. D2 is pretty good at figuring out how to draw the required graph, but it pays off to test out the [layout engines](https://d2lang.com/tour/layouts). Changing the [order of links](outputs-d2-link-node-attributes) might also unclutter the diagrams.
15
15
```
16
16
17
17
## Modifying Graph Attributes
@@ -27,15 +27,20 @@ Graphing routines use **[default](topo-defaults)** topology settings to modify t
27
27
28
28
[^DG]: The results look disgusting. If you find a better way to get it done, please submit a PR. Thank you!
29
29
30
-
(outputs-d2-style-attributes)=
30
+
(outputs-d2-link-node-attributes)=
31
31
## Modifying Link and Node Attributes
32
32
33
33
You can use the **d2** link and node attributes to change the style of individual nodes or links. The following attributes are built into _netlab_ (but see also [](outputs-d2-styles)):
34
34
35
35
***d2.color** -- line color (*stroke* in D2 lingo)
36
-
***d2.width** -- line width (*stroke-width*) in D2 lingo)
36
+
***d2.fill** -- fill color (*fill* in D2 lingo)
37
+
***d2.width** -- line width (*stroke-width* in D2 lingo)
37
38
38
-
You can also use the **d2.linkorder** link attribute to change the order of links in the D2 graph description file, which can sometimes improve the diagrams' appearance. Links with lower **d2.linkorder** value (default: 100) appear earlier in the list of links.
39
+
You can also use the **d2.linkorder** link attribute to change the order of links in the D2 graph description file, which can sometimes improve the diagrams' appearance. Links with lower **d2.linkorder** values (default: 100) appear earlier in the list of links.
40
+
41
+
```{tip}
42
+
The generic link- and node attributes can also be specified as **graph._attribute_** (for example, **graph.color**) values to use the same settings for GraphViz and D2 graphs.
43
+
```
39
44
40
45
## Modifying Shape and Connection Attributes
41
46
@@ -133,10 +138,10 @@ You can define your own link/node style attributes:
* Define a mapping between your attribute and D2 style attribute within the **defaults.outputs.d2.styles** dictionary. For example, your **d2.background** attribute maps into D2 **style.fill** attribute:
141
+
* Define a mapping between your attribute and D2 style attribute within the **defaults.outputs.d2.style_map** dictionary. For example, your **d2.background** attribute maps into D2 **style.fill** attribute:
137
142
138
143
```
139
-
defaults.outputs.d2.styles.background: fill
144
+
defaults.outputs.d2.style_map.background: fill
140
145
```
141
146
142
147
[^AD]: See [](dev-attribute-validation) and [](dev-valid-data-types) for more details.
Copy file name to clipboardExpand all lines: docs/outputs/graph.md
+16-1Lines changed: 16 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,22 @@ Graphing routines use **[default](topo-defaults)** topology settings to modify t
21
21
***outputs.graphs.node_address_label** (default: *True*) -- add node loopback IP addresses or IP addresses of the first interface (for hosts) to node labels.
22
22
***outputs.graph.rr_sessions** (default: *False*) -- draw IBGP sessions between BGP route reflectors and clients as directional connections.
23
23
24
-
You can also change the formatting of individual graph objects with the **outputs.styles._object_** defaults:
24
+
(outputs-graph-link-node-attributes)=
25
+
## Modifying Link and Node Attributes
26
+
27
+
You can use the **graph** link and node attributes to change the style of individual nodes or links. The following attributes are built into _netlab_[^XS]:
28
+
29
+
***graph.color** -- line color (*color* GraphViz attribute)
30
+
***graph.fill** -- fill color (*fillcolor* GraphViz attribute)
31
+
***graph.width** -- line width (*penwidth* GraphViz attribute)
32
+
33
+
You can also use the **graph.linkorder** link attribute to change the order of links in the D2 graph description file, which can sometimes improve the diagrams' appearance. Links with lower **graph.linkorder** values (default: 100) appear earlier in the list of links.
34
+
35
+
[^XS]: You can extend the GraphViz styling capabilities and add new **graph** attributes. See [](outputs-d2-styles) for details.
36
+
37
+
## Object Styles
38
+
39
+
You can also change the formatting of individual graph objects with the **outputs.graph.styles._object_** defaults:
Copy file name to clipboardExpand all lines: docs/release/2.0.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Release 2.0.1 includes [bug](bug-fixes-2.0.1) and [documentation](doc-fixes-2.0.
28
28
* SRv6: [BGP L3VPN support](module-srv6)
29
29
* Use the **routing** module to configure static routes on [**host** devices](node-role-host). VRF-aware devices can use a default route; other devices get more specific routes for address pools and named prefixes.
30
30
* Multiple [EVPN import/export route targets](evpn-vlan-service) allow you to build complex EVPN-based services like *common services* or *hub-and-spoke connectivity*
31
-
* Implement [node/link styles for D2 graphs](outputs-d2-style-attributes)
31
+
* Implement [node/link styles for D2 graphs](outputs-d2-link-node-attributes)
32
32
* Implement 'delete communities matching a list' in [routing policies](generic-routing-policies)
0 commit comments