graphvizstatechart

How to change font size of a single record item in Graphviz


I'm trying to create a state chart from Graphviz of type record. Please check the reference here.

So here is the basic code:

digraph lamp {
  node [shape=point,label=""]ENTRY
  node [style=rounded shape=record ]

  ON [label="{On| Some code here}"];
  OFF [label="{Off| Some code here}"];

  ENTRY -> ON[label="Initialization"]
  ON -> OFF[label="|toggle|"]
  OFF -> ON[label="|toggle|"]
}

In above code, I need to add some code below the state name like On and Off where I put the line Some code here. Since there will be a code and it can be any number of lines, I like to change the font size of this single record block where I will put the code (Not the state name record).

So in this line of code:

ON [label="{On| Some code here}"];

I like to change the font size of Some code here only not of On.

So, How can I get the control to independently change styling like font size or font name etc of the entered code here?


Solution

  • You can use html-like text, without building tables. (https://www.graphviz.org/doc/info/shapes.html#html). Like so:

    digraph lamp {
      node [shape=point,label=""]ENTRY
      node [style=rounded shape=record ]
    
      ON [label=<{<FONT COLOR="RED" POINT-SIZE="24.0">On</FONT>|<FONT COLOR="darkgreen" POINT-SIZE="10.0"> Some code here</FONT>}>];
      OFF [label=<{<FONT COLOR="black" POINT-SIZE="24.0">Off</FONT>|<FONT COLOR="darkred" POINT-SIZE="10.0"> Some code here</FONT>}>];
    
      ENTRY -> ON[label="Initialization"]
      ON -> OFF[label="  |toggle|  "]
      OFF -> ON[label="  |toggle|  "]
    }
    

    Giving:
    enter image description here