Records spanning over multiple lines in graphviz
Asked Answered
B

2

9

I am trying to visualize a rather complex structure in the dot language. Because the record is big, I would like to write the code in mulitple lines. So instead of:

A11[label="A.11 Access Control|{A.11.1 Business requirements for access control|A.11.2 User access management}|{A.11.3 User responsibilities|A.11.4 Network access control}|{A.11.5 Operating System access control|A.11.6 Application & information access control}|A.11.7 Mobile computing & teleworking"];

I would like to enter it somewhat like this

A11[label="A.11 Access Control|
           {A.11.1 Business requirements for access control|A.11.2 User access management}|
           {A.11.3 User responsibilities|A.11.4 Network access control}|
           {A.11.5 Operating System access control|A.11.6 Application & information access control}|
           A.11.7 Mobile computing & teleworking"];

Unfortunately the parser for dot complains about a "string running past line end" or something alike. Does anyone know how to denote a linebreak in the code? I tried a \ at the end of the line, but it didn't seem to work.

thanks in advance

Bronez answered 1/10, 2010 at 11:26 Comment(0)
S
10

I am guessing you want something like this:

graph G{
A11[label="A.11 Access Control|\n\
{A.11.1 Business requirements for access control|A.11.2 User access management}|\n\
{A.11.3 User responsibilities|A.11.4 Network access control}|\n\
{A.11.5 Operating System access control|A.11.6 Application & information access control}|\n\
A.11.7 Mobile computing & teleworking"];
}

You can also do like

label = "line1\n" +
        "line2\n" + ...
Somewhat answered 1/10, 2010 at 11:39 Comment(3)
Hi livibetter. No that is not what I meant. I would like to use multiple lines in the source code only. Just to make editing easier. So your solution without the \n but with just the \ does the trickBronez
I guess I assumed your want to the result to have multi-line too quick because I saw a really long line in result. Anyway, I am glad that I still can help with multi-line.Somewhat
Any ideas why this does not work in magjac.com/graphviz-visual-editor? I tried copy-pasting the above, inserting A11[ shape = Mrecord, label= ... and I only get a node with "A11" and no other text inside?! Also, if I change label="A.11 Access Control|\n` to label="A.11 Access Control|"+` and add a double quote on the next line, I get "ERROR: expected ... but "+" found"?Nila
S
0

Use \ to escape newlines without terminating the string. Note that you can insert whitespace before each {} to indent the lines in the source code. This whitespace has no effect on the generated graph.

graph G{
    node [shape=record];
    A11[label="A.11 Access Control|\
        {A.11.1 Business requirements for access control|A.11.2 User access management}|\
        {A.11.3 User responsibilities|A.11.4 Network access control}|\
        {A.11.5 Operating System access control|A.11.6 Application & information access control}|\
        A.11.7 Mobile computing & teleworking"
    ];
}

Demo here.

Subdivision answered 25/3 at 17:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.