Graphviz https://graphviz.org/ is a powerful tool for creating diagrams and visual representations of graphs using the DOT language. The DOT language allows you to describe the nodes and edges of a graph in a plain text format, which Graphviz then uses to render the graph visually.
Below is an overview of the features, along with examples demonstrating various elements of DOT syntax. For complete documentation on DOT syntax, visit the Graphviz documentation: https://graphviz.org/. You can find many more examples here: https://graphviz.org/gallery/.
In ReportServer, it's crucial to set the content type of your DOT file (e.g., myfile.dot) to ''text/vnd.graphviz''. This ensures that ReportServer recognizes the file as a DOT file and can convert it to SVG.
Features
Preview SVG Tab | Located in the file system administration window, this tab allows users to preview DOT content directly within ReportServer, rendered as SVG. |
Preview SVG Button | Found in the Properties tab of the file system administration window, this button renders the DOT content and exports it as an SVG in a new window. |
A DOT file consists of a graph definition, which includes nodes, edges, and their attributes. The basic structure of a DOT file is as follows:
Graph | Represents an undirected graph. |
Digraph | Represents a directed graph. |
Node | Represents a node in the graph. |
Edge | Represents an edge between two nodes |
Example of an Undirected Graph:
graph G {
A -- B;
B -- C;
C -- D;
D -- A;
}
This is a preview of the result rendering.
Example of a Directed Graph:
digraph G {
A -> B;
B -> C;
C -> D;
D -> A;
}
This is a preview of the result rendering.
Nodes and edges can be customized with various attributes such as labels, colors, shapes, and styles.
Example with node and edge attributes:
digraph G {
node [shape=circle, color=lightblue, style=filled];
A -> B [label="A to B", color=red];
B -> C [label="B to C", color=green];
C -> D [label="C to D", color=blue];
D -> A [label="D to A", color=purple];
}
This is a preview of the result rendering.
Below is an overview of node attributes:
shape | Defines the shape of the node (e.g., circle, box, ellipse). |
color | Defines the color of the node. |
style | Defines the style of the node (e.g., filled, dashed, dotted). |
Below is an overview of edge attributes
label | Defines a label for the edge. |
color | Defines the color of the edge. |
style | Defines the style of the edge (solid, dashed, dotted). |
Subgraphs are used to group nodes and edges together, which can help in organizing complex graphs or applying common attributes to a group of nodes and edges.
Example of Subgraphs
digraph G {
subgraph cluster_0 {
node [style=filled, color=lightgrey];
A -> B;
B -> C;
label = "Cluster 0";
}
subgraph cluster_1 {
node [style=filled, color=lightblue];
D -> E;
E -> F;
label = "Cluster 1";
}
C -> D;
F -> A;
}
This is a preview of the result rendering.
This is a preview of the result rendering.
An overview of the graph attributes is shown below.
rankdir | Defines the direction of the graph layout (TB for top to bottom, LR for left to right). |
bgcolorr | Defines the background color of the graph. |