Horizontal line in ellipse - graphviz

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

Related

Half-circle graphviz nodes

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.

How to have multiple rows in a node without setting `rankdir` nor using html tags

I need to plot nodes which have two rows. The top row is node name, and the bottom row is a condition. I am currently using the html-style table tag to achieve this. However, somehow I dislike this way. So, I am wondering if there is a more concise way without using html-style tags to do this. Note that I don't want to change rankdir=TB to rankdir=LR.
An example of my current approach, including code and output, is attached below. Thank you in advance.
digraph G {
node [shape=Mrecord]
aNode [ label=<
<table border='0'>
<tr><td bgcolor='gray'>nodeName</td></tr>
<tr><td>condition</td></tr></table>
> ];
}
Putting {} around the text in your label will change the direction of the record separators.
digraph {
graph [rankdir=TB];
node [shape=Mrecord];
item [label="{one | two}"];
}

Graphviz: Putting a Caption on a Node In Addition to a Label

In my Graphviz graph (written in DOT), I want each node to have a label, but in addition to that, I want some nodes to have a small caption denoting some other unique value for that node. For example, if this were for a history diagram, a node's label might be something like "Birth of George Washington" and the caption might read "See also: American Revolution."
This is fairly flexible, so the caption doesn't necessarily need to be inside the node, but I do need some other way of putting text that clearly isn't part of the label (e.g. is a different size, possibly a different color) and is in a different location but is still clearly a part of the node.
Is there any way to do this?
To place captions outside the node, you may use xlabel:
digraph g {
forcelabels=true;
a [label="Birth of George Washington", xlabel="See also: American Revolution"];
b [label="Main label", xlabel="Additional caption"];
a-> b;
}
forcelabels=true makes sure no xlabel is omitted.
A second option is to use HTML-like labels:
digraph g {
a[label=<Birth of George Washington<BR />
<FONT POINT-SIZE="10">See also: American Revolution</FONT>>];
}

label hyperlink Graphviz

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];

Graphviz: Color only a field in a Record-based Node

Is there a way to add color to only a field in a record-based node. Like in the following example, can the field struct2:f0 alone be in different color?
digraph structs {
node [shape=record];
struct1 [label="<f0> left|<f1> mid\ dle|<f2> right"];
struct2 [label="<f0> one|<f1> two"];
struct3 [label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
}
Thx
I don't think this is possible.
You may consider using HTML-like labels - you should be able to do everything you can do with record-based nodes, and more.
From the above linked documentation page:
The record-based shape has largely been superseded and greatly
generalized by HTML-like labels. That is, instead of using
shape=record, one might consider using shape=none and an HTML-like
label.
and
Although HTML labels are not, strictly speaking, a shape, they can be
viewed as a generalization of the record shapes described above. In
particular, if a node has set its shape attribute to none or
plaintext, the HTML label will be the node's shape.
Try this:
digraph G {
"Record" [ label=<<table>
<tr>
<td>A</td>
<td bgcolor='#00CC11'>B</td>
</tr>
</table>
>
];
}

Resources