onepiece
onepiece

Reputation: 3539

Line break for components

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?

Upvotes: 10

Views: 11867

Answers (2)

Frelling
Frelling

Reputation: 3507

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

Upvotes: 10

Peter Uhnak
Peter Uhnak

Reputation: 10217

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

}

Upvotes: 3

Related Questions