I'm trying to use the dot program included with GraphViz (version 2.28.0 (20121023.0419)) to convert the following graphviz file:
digraph {
1 [
shape=none
,label=<<TABLE BGCOLOR="lightblue2" BORDER="0" CELLBORDER="0" STYLE="rounded" ><TR><TD><FONT FACE="Helvetica" POINT-SIZE="20">Heading 1</FONT></TD></TR>
<TR><TD>Body 1<BR /></TD></TR></TABLE>>
];
3 [
shape=none
,label=<<TABLE><TR><TD><FONT FACE="Helvetica" POINT-SIZE="16">Heading 2</FONT></TD></TR>
<TR><TD>Body 2<BR /></TD></TR></TABLE>>
,color=lightblue2];
2 [
shape=none
,label=<<TABLE><TR><TD><FONT FACE="Helvetica" POINT-SIZE="16">Heading 3</FONT></TD></TR>
<TR><TD>Line 1<BR />Line 2<BR /></TD></TR></TABLE>>
,color=lightblue2];
}
First, I tried running to create a PDF (same result on Linux and Mac OS):
dot -Tpdf -Gcharset=utf8 test.dot > output.pdf
Issues:
Incorrect font rendering: Heading 1 is underlined, the Heading 3 is italic, but all of them are specified using the exact same font face.
Border around the first node: I specified BORDER="0" but apparently the border is visible anyway when using STYLE="rounded"...
Next I tried to create an SVG file instead, which solves the font rendering issues:
dot -Tsvg -Gcharset=utf8 test.dot > output.svg
As you can see the text overflows the borders of the node. This happens even if I add a FIXEDWIDTH="FALSE" to the table.
What am I doing wrong?
Good daytime!
I advise you to try downgrading to dot-graphviz of 2.26.3 version. I did the same as you and got the correct result apart from the fact that dot-program ignored attribute STYLE in first table. So it was not rounded.
Related
Is it possible to have graphviz/dot render a node as a circle that is split in the middle horizontally, with a top and bottom text content? Something like a record, but the final shape should be a circle. Currently I'm using Mrecord, but that's only a rounded rectangle, not a circle shape.
I searched for ways to increase the border radius of Mrecord (to make it a quasi-circle) but that did not work. I also tried Mcircle, which is not what I was looking for.
Not directly, but you can create a circle-shaped node, divided in half with the wedged attribute and in the HTML-like label write a HTML <TABLE> without borders which will place text on top of the node.
Script:
digraph {
nodepie [shape = "circle"
style = "wedged"
fillcolor="white;0.5:white"
label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0">
<TR>
<TD>one</TD>
</TR>
<TR>
<TD>two</TD>
</TR>
</TABLE>>];
}
Result:
Not directly, but you can create an image (svg, png, ...) that looks exactly like you want, using any drawing program, & then include that image in your Graphviz graph.
I want to use graphviz for my use-cases, is there an easy way of getting a horizontal line in an ellipse shape?
image for reference:
(source: highscore.de)
if I use
digraph G {
Case [
label = "{Use-Case C | Extension points \l blablabla}"
shape = "record"
]
}
I get a square with the horizontal line, but as soon as I change from record to ellipse the label has the text "{Use-Case C | Extension points \l blablabla}"
Actually, ellipse and record are different types of nodes. Vertical bar in record is used as a horizontal line just by convention. It is impossible to draw it in ellipse like that.
But there is a workaround here.
According to another question about horizontal lines you can try HTML labels while using tables. They won't give you exactly what you want. Still, it is possible to draw label like that:
digraph structs {
node [shape=ellipse]
A [label=<
<TABLE BORDER="0" CELLSPACING="0">
<TR><TD>top</TD></TR>
<HR/>
<TR><TD>bottom</TD></TR>
</TABLE>
>];
B [label="Hello, Graphviz"];
A -> B;
}
Whereas the result looks like:
Ultimately, you may try creating your custom shape
Following is code using dot language.
subgraph cluster1
{
node[style=filled];
color=blue;
b0->b1;
label ="Tada"; // I want this to show as underlined.
}
You can use HTML-like labels and the <u> tag:
digraph cluster1
{
node[style=filled, color=blue];
b0->b1;
label = <<u>Tada</u>>; // I want this to show as underlined.
}
This is the result:
Note that your color=blue statement wasn't applied to any element. I moved it into node.
As pointed out in the comments, this currently only works for svg output. I tried with png and pdf on my Mac running 10.14.6 and they weren't underlined.
I try to find out in Graphviz, how to make a label "1" colored and at the same time a hyperlink. Is this possible? Please see the example below.
F
<graphviz>
digraph vvv
{
rankdir=LR
a2 [href="http://www.apple.com"]
{
a0->a1[href="http://www.uk.com"] [label="1"] [color =red];
a1->a2
}
a2[style=filled,color=yellow]
a0[style=filled,color=lightgrey]
</graphviz>
Yes it's possible.
I'm assuming you are generating SVG output.
If by make a label "1" colored you mean the font color of the label text, it's as simple as specifying it in the edge attributes:
a0->a1[href="http://www.uk.com", fontcolor=yellow, color=red label="1"];
fontcolor refers to the color of the label's text, whereas color is the color of the edge itself.
If you want to have an edge label with a colored background, fillcolor is supposed to work. However, it doesn't (may depend on the version of graphviz). Therefore you may use HTML-like labels and specify the BGCOLOR:
a0->a1[href="http://www.uk.com", fontcolor=red, label=<
<TABLE CELLBORDER="0" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR><TD BGCOLOR="yellow">1KMK</TD></TR>
</TABLE>
>, color =red];
I generate SVGs using Graphviz. When embedded in HTML, the nodes, edges and arrows show an "_anonymous_0" tooltip. Can I get rid of these from within GraphViz?
Found by trial and error :-)
digraph "my title" {
tooltip=" "
node [tooltip=" "]
edge [tooltip=" "]
...
}
disables the automatic generation of tooltips.
an empty string
tooltip=""
does not(!) disable the generation.
If your dot source start something like this:
digraph {
it may help to use the following:
digraph "" {
It looks like the name of the graph (digraph mygraph { ) is transformed to a title element (<title>mygraph</title>). If you omit the name, *anonymous_0* is used instead. But if "" is used, no title element is being created.
There may be a better solution to this though...