Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graphviz: record node with a bold title

I'm trying to use graphviz to do something similar to UML class diagrams.

I wonder whether there is a way to make a node of style 'register' have its first field in a bold font, to make it different from the other fields.

My node looks like this:

digraph i { 
  "node" [
    label = "<f0> title | <f1> index | ... | <f2> field1 | <f3> field2"
    shape = "record"
  ];  
}

I tried this but it doesn't work: (embedding html)

digraph i { 
  "node" [
    label = "<f0> <B>title</B> | <f1> index | ... | <f2> field1 | <f3> field2"
    shape = "record"
  ];  
}
like image 607
eordano Avatar asked May 30 '11 00:05

eordano


1 Answers

I don't believe record-based nodes allow HTML formatting in them. The node shape documentation suggests that record-based nodes have been deprecated in favor of using a none-shaped node with an HTML-like label, which is much more flexible with formatting. These labels are surrounded with <> instead of double quotes.

I haven't been able to test this, but this is close to what you want:

digraph i { 
  "node" [
    label =<<TABLE BORDER="1" CELLBORDER="1" CELLSPACING="0">
                    <TR><TD PORT="f0"><B>title</B></TD></TR>
                    <TR><TD PORT="f1">index</TD></TR>
                    <TR><TD PORT="f2">field1</TD></TR>
                    <TR><TD PORT="f3">field2</TD></TR>
                </TABLE>>
    shape = "none"
  ];  
}

Output:

enter image description here

like image 86
Dan Avatar answered Nov 09 '22 19:11

Dan