How to fix class positioning to correctly display the member-ends and multiplicities of their relationships

0 votes
asked Jun 22 in Question / help by Jean-Marc

Hello,

I'd like to use PlantUML to represent class diagrams.
However, I don't succeed to fix class positioning to correctly display the UML member-ends and multiplicities of their relationships.
Can you have a look to my markup given below please.
By member-ends I'm talking about AccountId__c, Metric__c, AccountId, and Opportunities.
By multiplicities I'm talking about 0..1 and 0..*.
If you copy-paste my markup in PlantUML, you will see that classes are not well positioned  
The following picture displays what I want versus what I get.
Can you help me please?


Here is my markup in the editor

@startuml

hide circle
hide methods

skinparam ClassHeaderBackgroundColor White
skinparam ClassBackgroundColor White

class "<color:DodgerBlue>**Account**</color>" #line:DodgerBlue
class "<color:DodgerBlue>**Opportunity**</color>" #line:DodgerBlue
class "**AccountMetric__c**"


"<color:DodgerBlue>**Account**</color>" : {field} <color:DodgerBlue>Id: Text(18)</color>
"<color:DodgerBlue>**Account**</color>" : {field} <color:DodgerBlue>Name: Text(50)</color>
"<color:DodgerBlue>**Account**</color>" : {field} PreferedColor: Text(30)

"<color:DodgerBlue>**Opportunity**</color>" : {field} <color:DodgerBlue>Id: Text(18)</color>
"<color:DodgerBlue>**Opportunity**</color>" : {field} <color:DodgerBlue>Name: Text(50)</color>

"**AccountMetric__c**" : {field} <color:DodgerBlue>Id: Text(18)</color>
"**AccountMetric__c**" : {field} <color:DodgerBlue>Name: Text(50)</color>
"**AccountMetric__c**" : {field} Date: DateTime
"**AccountMetric__c**" : {field} Label: Text(200)
"**AccountMetric__c**" : {field} Value: Number(18,2)

"<color:DodgerBlue>**Account**</color>" "AccountId 0..1" <-- "Opportunities 0..*" "<color:DodgerBlue>**Opportunity**</color>" #line:DodgerBlue;text:DodgerBlue
"<color:DodgerBlue>**Account**</color>" "AccountId__c\n0..1" <- "Metrics__c\n0..*" "**AccountMetric__c**"

@enduml

1 Answer

0 votes
answered Jun 24 by The-Lu (67,040 points)

Hello J.,

Here is a proposal adding an empty label, as:

@startuml

hide circle
hide methods

skinparam ClassHeaderBackgroundColor White
skinparam ClassBackgroundColor White

class "<color:DodgerBlue>**Account**</color>" #line:DodgerBlue
class "<color:DodgerBlue>**Opportunity**</color>" #line:DodgerBlue
class "**AccountMetric__c**"

"<color:DodgerBlue>**Account**</color>" : {field} <color:DodgerBlue>Id: Text(18)</color>
"<color:DodgerBlue>**Account**</color>" : {field} <color:DodgerBlue>Name: Text(50)</color>
"<color:DodgerBlue>**Account**</color>" : {field} PreferedColor: Text(30)

"<color:DodgerBlue>**Opportunity**</color>" : {field} <color:DodgerBlue>Id: Text(18)</color>
"<color:DodgerBlue>**Opportunity**</color>" : {field} <color:DodgerBlue>Name: Text(50)</color>

"**AccountMetric__c**" : {field} <color:DodgerBlue>Id: Text(18)</color>
"**AccountMetric__c**" : {field} <color:DodgerBlue>Name: Text(50)</color>
"**AccountMetric__c**" : {field} Date: DateTime
"**AccountMetric__c**" : {field} Label: Text(200)
"**AccountMetric__c**" : {field} Value: Number(18,2)

"<color:DodgerBlue>**Account**</color>" "AccountId 0..1" <-- "Opportunities 0..*" "<color:DodgerBlue>**Opportunity**</color>" #line:DodgerBlue;text:DodgerBlue
"<color:DodgerBlue>**Account**</color>" "AccountId__c\n0..1" <-r---- "Metrics__c\n0..*" "**AccountMetric__c**" : "\t\t\t\t\t"

@enduml

Enjoy,
Regards,
Th.

commented Jun 26 by Jean-Marc
Thanks a lot for your tips

So, you mean you need to add a fake relationship name made of as many tabs as necessary with regards to the length of the member-ends names’ lengths.

There is no PlantUML « option » to ask for automatic positioning that take into account the member-ends names.

Is this a relevant evolution to consider?
...