nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
937 stars 107 forks source link

using style in subgraphs #180

Open UltraBuk opened 4 years ago

UltraBuk commented 4 years ago

Hello, I use your great project for the visualization of algorithms. Unfortunately there seems to be no support for styles in subgraphs when using GraphvizV8Engine (v0.16.3), the execution returns: INFO guru.nidi.graphviz.model.Serializer - ERROR graph attrs of 'cluster1_0' -> 'style' is not allowed for subgraphs. I need to add an invisible subgraph to increase the nodesep between two graphs. Do you have any suggestions or solutions to solve this issue?

It would be cool if you could have a look at it. Thanks a lot :)

manikmagar commented 4 years ago

I use v0.17.0 and GraphvizV8Engine . I am able to add an invisible cluster to create space between two other cluster. Here is how my space cluster looks -

graph("legend-space")
            .cluster()
                .graphAttr()
                .with(Label.of(""), Style.INVIS)
            .with(node("")
                    .with(Shape.NONE,
                            Size.std().size(2,1)))  //Adjust the height of this to change spacing
            .addTo(rootGraph);
nidi3 commented 3 years ago

As per http://www.graphviz.org/doc/info/attrs.html#d:style style is not supported for subgraphs. But it is for clusters. So you can use @manikmagar's solution or use clusters instead of plain subgraphs.