Plantuml several arrows between two classes

Viewed 131

I am trying to draw a class diagram where several relationships between two classes are defined with multiplicities.

By default, the results are horrible:

@startuml

class Movie {
    genres: String[]
    minutes: Integer
    movie_id: String
    rating: Float
    title: String
    type: String
    votes: Integer
    year: Integer
}

class Person {
    birthYear: Integer
    deathYear: Integer
    name: String
    person_id: String
}

Person "0..*" -> "1..*" Movie : acted_in
Person "0..*" -> "1..*" Movie : directed
Person "0..*" -> "1..*" Movie : produced
Person "0..*" -> "1..*" Movie : wrote

@enduml

Output of default layout

With skinparam nodesep 200 it is a little better, but the multiplicities are still off:

Output with nodesep 200

I also tried with skinparam linetype ortho, which looked promising, but gets messed up as soon as I also add hide circle and hide methods

Output with linetype ortho, hide circle and hide methods

Not to mention that eventually I would also like to add an association class, which really ruins it:

Output with association class

Here is the final code:

skinparam nodesep 200
skinparam linetype ortho
hide circle
hide methods

class Movie {
    genres: String[]
    minutes: Integer
    movie_id: String
    rating: Float
    title: String
    type: String
    votes: Integer
    year: Integer
}

class Person {
    birthYear: Integer
    deathYear: Integer
    name: String
    person_id: String
}

Person "0..*" -> "1..*" Movie : acted_in
Person "0..*" -> "1..*" Movie : directed
Person "0..*" -> "1..*" Movie : produced
Person "0..*" -> "1..*" Movie : wrote
(Person,Movie) .. Role

class Role {
    name: String
}

@enduml

My question is: is there a way to draw this properly with PlantUML?

1 Answers

I don’t know how to directly reach your goal of a more legible arrow layout but you could avoid the problem by using Person as a generalisation for four sub-classes such as Actor, Director, Producer and ScreenplayWriter. Each of these would have separate arrows and it might make your diagramme also generally clearer (the latter is, of course, subject to your taste and the diagramme’s purpose)

Related