haba713
haba713

Reputation: 2677

CSS Stylesheets in Graphviz

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?

Upvotes: 4

Views: 1981

Answers (1)

haba713
haba713

Reputation: 2677

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

Upvotes: 7

Related Questions