CSS Stylesheets in Graphviz

Viewed 370

Graphviz supports CSS stylesheets for SVG ouptut. There's an attribute stylesheet in the documentation.

Should the attribute stylesheet be given separately to all the nodes? How can I set a stylesheet for all the graph elements just writing the CSS filename to one place only? Where?

1 Answers

The attribute stylesheet is given to a graph definition. See the sample below.

sample.dot

graph sample {
    stylesheet="sample.css"
    a [class="sky"]
    b [class="ground"]
    a -- b
}

sample.css

.sky>ellipse {
    fill: deepskyblue;
}

.ground>ellipse {
    fill: palegreen;
}

command

dot -Tsvg < sample.dot > sample.svg

sample.svg

enter image description here

Related