9

My PlantUML code looks like this

package "parent" {
  package "child1" {
  }

  package "child2" {
  }

  package "child3" {
  }

  //and so on...
}

The rendered diagram has all the child packages side by side and so the diagram is too wide. Is there a way to force all packages after child2 to be below (line break) the previous packages?

onepiece
  • 3,279
  • 8
  • 44
  • 63

2 Answers2

9

As mentioned in this answer, the simplest approach approach is to use hidden links. However, to ensure better layout and minimize the number of hidden links, use the together keyword to "group" objects. All objects in a group will maintain the same relative position set by a single link.

An expanded version of your example

package "parent" {
  together {
    package "childA2" {
    }

    package "childA1" {
    }
  }

  together {
    package "childB4" {
    }

    package "childB3" {
    }

    package "childB2" {
    }

    package "childB1" {
    }
  }


  together {
    package "childC2" {
    }

    package "childC1" {
    }
  }
  childA1 -[hidden]-> childB1
  childB1 -[hidden]-> childC1
}

would yield the following diagram.

enter image description here

Community
  • 1
  • 1
Frelling
  • 3,287
  • 24
  • 27
3

The typical approach is to add hidden edges, as described in the Help on layout section of PlantUML.

e.g.

package "parent" {
  package "child1" {
  }

  package "child2" {
  }

  package "child3" {
  }

  child1 -[hidden]-> child2
  ' you can add more space by adding more dashes
  child2 -[hidden]---> child3

}
Peter Uhnak
  • 9,617
  • 5
  • 38
  • 51