Unexpected padding in note of a class diagram with graphviz included. How can I remove that padding ?

0 votes
asked May 12, 2022 in Question / help by Filippo
Here is an example where I include a graphviz diagram into a note of a class diagram.
I would like to have the note fit the diagram as it does for salt diagrams for example or for simple text.
But it doesn't. The note leaves an unexpected blank space between the diagram and its border.
And the blank space becomes larger with larger diagrams.
Can we remove that space?

@startuml
note bottom of MyClass
{{
digraph G {
    margin=0
    bgcolor="white"
    node[shape=box; color=none; shape=plaintext; fontsize=12; nodesep=0.1; ranksep=0.1]
    methodOne -> methodTwo
}
}}
end note
class MyClass {
    <back:myGreen>methodOne()</back>
    <back:myGreen>methodTwo()</back>

}
@enduml

Thank you
commented May 12, 2022 by Martin (8,360 points)
moved May 14, 2022 by Martin

I'm note sure if Salt does fit the note perfectly - there is a white border, eg


Turning borders back on in your diagram shows the problem better:

Adding "graph [pad=0]" helps:

although it is lucky you didn't want borders, as they do seem to be slightly clipped!

commented May 12, 2022 by Filippo
edited May 12, 2022

Sorry, my issue is not the white part in the graphviz diagram but rather the yellow part in the note.
It even expands when the graphviz diagram gets bigger.

Try with that class diagram to see it : 

```

@startuml
note top of MyClass
{{
digraph G {
    margin=0
    bgcolor="white"
    node[shape=box; color=none; shape=plaintext; fontsize=12; nodesep=0.1; ranksep=0.1]
    methodOne -> methodTwo
    methodThree -> methodTwo
    methodFour -> methodTwo
    methodFive -> methodTwo
}
}}
end note

class MyClass {
    <back:myGreen>methodOne()</back>
    <back:myGreen>methodTwo()</back>
    <back:myGreen>methodThree()</back>
    <back:myGreen>methodFour()</back>
}
@enduml

```
 

commented May 12, 2022 by The-Lu (64,340 points)

Yes, that is a funny example, just a "magin=1":

@startuml
note top of MyClass #red
{{
digraph G {
    margin=1
    bgcolor="white"
    node[shape=box; color=none; shape=plaintext; fontsize=12; nodesep=0.1; ranksep=0.1]
    methodOne -> methodTwo
    methodThree -> methodTwo
    methodFour -> methodTwo
    methodFive -> methodTwo
}
}}
end note

class MyClass {
    <back:myGreen>methodOne()</back>
    <back:myGreen>methodTwo()</back>
    <back:myGreen>methodThree()</back>
    <back:myGreen>methodFour()</back>
}
@enduml

Regards.

commented May 13, 2022 by Filippo
Is there a way to fix that issue ?

The issue is not only in notes. It has to do with the graphviz integration itself.
When I put a graphviz diagram in a class I have the same issue.
Example :

@startuml
class ClassOne {
    <back:myGreen>methodOne(...)</back>
    ..
    <back:myGreen>Does what it says</back>
    --
    <back:myGreen>methodTwo(...)</back>
    ..
    <back:myGreen>Does what it says</back>

    {{
    digraph G {
        margin=0
        bgcolor="white"
        node[shape=box; color=none; shape=plaintext; fontsize=12; nodesep=0.1; ranksep=0.1]
        subgraph cluster_0 {
            label="ClassOne"
            methodOne, methodTwo
        }
        subgraph cluster_1 {
            label="ClassTwo"
            methodThree    
        }
        methodOne -> methodThree
        methodTwo -> methodThree
    }
    }}
}
@enduml

I would like to attach the rendered diagram but I don't know how to.
When I paste an image the form complains I am using too many characters.
commented May 13, 2022 by The-Lu (64,340 points)

Here is the corresponding image, and here is another issue, compare PNG output with SVG output...

PNG:

SVG:


 

See also pseudo-similar issue (not with dot/graphiz but with sub-diagram) here:

If that can help,
And for testing by @PlantUML team,

Regards.

commented May 14, 2022 by Martin (8,360 points)
edited May 14, 2022 by Martin
Ah I see, I didn't realise this problem only occurs in SVG and not PNG.

1 Answer

0 votes
answered May 16, 2022 by valexiev (1,200 points)
"Note" has a certain shape (with a dog-eared corner), so it has to allow for some margin for that shape to be visible.

Have you guys tried using a rectangle node instead of a Note?
commented May 16, 2022 by The-Lu (64,340 points)

Hello V.,

Same thing with rectangle, as PNG vs SVG:

PNG:

SVG:

If that can help for debugging...

commented Oct 29, 2022 by kasra (1,000 points)
Hi,

Any news about that bug ?

Thanks
...