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];
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 am wanting to change the background color of an edge label in Graphviz. At the moment the only way I can see of doing this is using an HTML table.
Eg,
edge [len=3,fontcolor=red];
DeviceA -- DeviceB [headlabel=<
<table border="0" cellborder="0">
<tr>
<td bgcolor="white">Head Label</td>
</tr>
</table>>
,taillabel="Tail Label"];
What I would like to be able to do is something shorter/cleaner:
edge [len=3,fontcolor=red,bgcolour=white];
DeviceA -- DeviceB [headlabel="Head Label",taillabel="Tail Label"];
Is their an option for this in graphviz?
The reason I am trying to do this is because end labels end up written over edges, which makes the label difficult to read, a background color the same color as the canvas, artificially creates a break in the edge.
Thanks
In GraphViz there is no way to change the Background Colour of an Edge Label. However you can achieve the same by using a HTML Table:
Eg:
edge [len=3,fontcolor=red];
DeviceA -- DeviceB [headlabel=<
<table border="0" cellborder="0">
<tr>
<td bgcolor="white">Head Label</td>
</tr>
</table>>
,taillabel="Tail Label"];
I would like to have arrows go "through" a box, not from box to box. Is there a way to accomplish this (see below) in graphviz?
(Why am I asking: I have some data flow diagrams where multiple outputs from an entity are going through the same entity to be passed to the last entity, and the graphviz output looks like this:
eg., I find this not nice and not recognizable.)
This doesn't exist in graphviz.
How about simply omitting the arrow heads in the edges from A/B to C ?
digraph G {
node[shape=box];
{A;B} -> C [arrowhead=none];
C -> D;
C -> D;
}
Edit: unless, you really want to do that ...
... then you could use HTML-like labels for the node which should have edges crossing through, define ports within the label to attach edges to (in this case, "ww" and "ee"), and have an edge going to the port without an arrow head, as well as an edge leaving from the port with an arrow head, creating the illusion of a single arrow crossing through the port (which isn't visible as such).
digraph G {
node[shape=box];
C[label=<
<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD port="ww"></TD>
<TD></TD>
<TD port="ee"></TD>
</TR>
<TR>
<TD></TD>
<TD CELLPADDING="5">C</TD>
<TD></TD>
</TR>
</TABLE>
>];
A -> C:ww:n [arrowhead=none];
B -> C:ee:n [arrowhead=none];
C:ww:s -> D;
C:ee:s -> D;
}
In order to have nices arrow curves, I also defined compass points for the edges - compass points are n/e/s/w and determine from which side an edge is supposed to enter/leave.
I have a very simple graph:
digraph {
node [shape=rect];
rankdir=LR;
A -> B
}
It outputs as I expect:
However, I need to place unique numbers in each corner of both A and B. I am currently only aware of xlabel, but from what I gather can only be used once and cannot be specified in a particular region. So how can I accomplish writing numbers in each corner?
Newest versions of Graphviz support HTML styling of nodes, including tables ("newer than mid-November 2003", that is). So you can make a 3x3 table like this:
Source:
digraph {
node [shape=rect];
rankdir=LR;
A [shape=none label=<
<TABLE BORDER="0" CELLBORDER="0">
<TR><TD>1</TD><TD></TD><TD>2</TD></TR>
<TR><TD COLSPAN="3" BORDER="1">A</TD></TR>
<TR><TD>3</TD><TD></TD><TD>4</TD></TR>
</TABLE>
>];
A -> B
}
Tested with http://sandbox.kidstrythisathome.com/erdos/; it also works with my local installed version (2.38.0).
See Graphviz: Node Shapes for the full set of supported HTML, and examples.
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