Search code examples
htmlgraphvizclass-diagramdot

Underline part of label in DOT (graphviz)


I want to create my class diagram with DOT and therefore I need to underline the static methods.

Currently my source is:

digraph G {                                                                
    fontname = "Bitstream Vera Sans"                                       
    fontsize = 8                                                           

    node [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
        shape = "record"                                                   
    ]                                                                      

    edge [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
    ]                                                                      

    subgraph packagemodel {                                                

        Class [                                                            
            label = "{Classname|\l\                                        
                + attribute|\l\                                            
                + staticfunction}"                                         
        ]                                                                  
    }                                                                      
}

but I did not find out how to make a part of a label underlined. Do you know that could be made?

Thanks in advance!

UPDATE:

I now changed it to:

digraph G {                                                                
    fontname = "Bitstream Vera Sans"                                       
    fontsize = 8                                                           

    node [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
        shape = "record"                                                   
    ]                                                                      

    edge [                                                                 
        fontname = "Bitstream Vera Sans"                                   
        fontsize = 10                                                      
    ]                                                                      

    subgraph packagemodel {                                                

        Class [
            label =
            <<table border="0" cellspacing="0" cellborder="1">             
            <tr>                                                       
                <td>Sudoku3DFactory</td>                               
            </tr>                                                      
            <tr>                                                       
                <td>attribute</td>                                              
            </tr>                                                      
            <tr>                                                       
                <td><u>+ staticfunction</u></td>  
            </tr>                                                      
            </table>>
        ]
    }
}

but it is still not underlined.


Solution

  • You need to change from shape = record to shape = plain. On some systems, this shape is not available, on mine for example, then this helps:

    digraph G {                                                                
        fontname = "Bitstream Vera Sans"                                       
        fontsize = 8                                                           
    
        node [                                                                 
            fontname = "Bitstream Vera Sans"                                   
            fontsize = 10                                                      
            shape = none width=0 height=0 margin=0   // this _is_ plain                               
        ]                                                                      
    
        edge [                                                                 
            fontname = "Bitstream Vera Sans"                                   
            fontsize = 10                                                      
        ]                                                                      
    
        subgraph packagemodel {                                                
    
            Class [
                label =
                <<table border="0" cellspacing="0" cellborder="1">             
                <tr>                                                       
                    <td>Sudoku3DFactory</td>                               
                </tr>                                                      
                <tr>                                                       
                    <td>attribute</td>                                              
                </tr>                                                      
                <tr>                                                       
                    <td><u>+ staticfunction</u></td>  
                </tr>                                                      
                </table>>
            ]
        }
    }
    

    This produces

    enter image description here

    including the underline.