Please allow adding edges to class members and methods with complex names

+1 vote
asked Dec 8, 2016 in Closed feature request by anonymous

Hi! I am using PlantUML to generate simple ER diagrams, utilizing class keyword for describing entities.

Currently there is a way to link two properties or methods using class1::prop -- class2::prop syntax, but it doesn't work with complex property names that contain formatting. 

Here is an example of what I am trying to do:

hide empty methods
hide circle

skinparam linetype ortho

!define PK <size:12><&key></size><b>
!define FK <size:12><&link-intact></size><i>
!define PP <size:12><&caret-right></size>

class "<b> Some dict </b>" as d {
    PK ID        \t\t\t Integer
    PP Name          \t String
}

class "<b> Some entity </b>" as e {
    PK ID       \t\t Integer
    FK Type     \t\t Integer
    PP Some field \t JSON
}

e::Type }-- d::ID

I tried to put full property name in quotes like this:  e::"FK Type \t\t Integer" }-- d::"PK ID \t\t\t Integer", but all I get is a syntax error.

Please allow adding edges to class members and methods with complex names.

1 Answer

0 votes
answered Dec 9, 2016 by plantuml (295,000 points)
 
Best answer

This feature is under development, but we fixed several issue in the last beta. We also enhanced it so that you can use in your case.

With this beta: https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

Now, the following diagram is working:

@startuml
hide empty methods
hide circle

'skinparam linetype ortho

!define PK <size:12><&key></size><b>
!define FK <size:12><&link-intact></size><i>
!define PP <size:12><&caret-right></size>

class "<b> Some dict </b>" as d {
    PK ID      \t\t Integer
    PP Name    \t String
}

class "<b> Some entity </b>" as e {
    PK ID       \t\t Integer
    FK Type     \t\t Integer
    PP Some field \t JSON
}

e::Type }-- d::ID

@enduml

Unfortunately, the skinparam linetype ortho does not work very well, and there is nothing we can really do here (all this is managed by Graphviz/Dot).

Well, there may be one solution: we could still request Graphviz/Dot to do B-splines, and then we could transform those B-splines into segment for the drawing.
Not sure that it will give some good drawing. And it needs some work.

Another thing that we can do is to enhance crowfoot drawing to only handle 0/90/180/270 angle (should be easy to do).

Does it sound good to you?

commented Dec 9, 2016 by anonymous
I don't really need the ortho mode and I only turned it on to make crownfoots placed at 90 deg angles, but yeah, it didn't work well. So I think it would be good if crownfoots are placed only at 0/90/180/270 deg angles.
commented Dec 9, 2016 by plantuml (295,000 points)
The crowfoots should be better in last beta:
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
Not highly tested, so feedback welcome!
commented Dec 9, 2016 by anonymous
Just tried it on couple somewhat large (10-15 entities) diagrams, works great! Crowfoot ends are nicely attached to edges everywhere.
The only problem I noticed is a strange class members matching.

Here is an example:

class A {
 PK ID Integer
 FK OSM_ID BigInteger
 PP OtherID Integer
}
A::ID -- B::Field

In this case the line will be drawn not from ID property of A, but from OtherID property. I guess it just matches the last line that contains "ID" somewhere, even if it is just a part of a word?
commented Dec 10, 2016 by plantuml (295,000 points)
You're correct.

So in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
If several properties contains the "ID" substring, then it has to be an exact word, and not only a part of a word.
So your last example is now working.

All this may sounds strange, but we are trying to have something short in <classname>::<ID> notation.
Tell us if you find other issues!
Thanks
commented Sep 18, 2019 by valexiev (1,200 points)

Another example show-casing how the ports (arrow-ends) align with the fields

commented Dec 6, 2019 by aspiers (100 points)

If several properties contains the "ID" substring, then it has to be an exact word, and not only a part of a word.

Unfortunately this does not help if the property you want to point to is a substring of other properties in the same class.  For example here I want Email::user_id to point to User::id but it actually points at User::other_id because "id" is a substring of "other_id", and I can't see any way to prevent this and get the arrow pointing at the right member.

http://www.plantuml.com/plantuml/uml/TSsngi9048NXVfxYr1UI1zWgJRZOM8ZMicH6Cx39mini9RwxY5f4i3vy_nayiaLR2XMv1AB2z3e7M4scqBeIJIMxu-HYk16WZ8JT_ZZ-ZmS2-fw06hFOURFSFt1SifQVilat13ApYViszlnFIHb_NVTgflJ6DCZARIaF

commented Dec 6, 2019 by plantuml (295,000 points)
Your last example seems to work with last beta http://beta.plantuml.net/plantuml.jar
commented Dec 14, 2021 by thjungers (100 points)

This seems to work only if the desired member appears first in the class.

In this example, the arrow is expected to point to "id", but points to "id2" because it comes first in the class definition:

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuSf9JIjHACbNACfCpoXHICaiIaqkoSpFu-9ApaaiBbO8BKujKgZcKb38J35Ii5Bmz0jnTNSD0lBrzC22I6ArC3skkOcPEL1Dc7fAWIR6eqaafgGKfHONene6ijhA2gXIIrSNOgQL5LGpbqDgNWhGzG00

How could this be set up so the arrow points to "id" instead?

Alternatively, is it possible to define aliases for members and use them as endpoints for arrows? This would allow using unique names and prevent mismatches.

commented Dec 14, 2021 by plantuml (295,000 points)

Thanks for the report.

This is fixed on the online server and with last snapshot.

Alternatively, is it possible to define aliases for members and use them as endpoints for arrows? This would allow using unique names and prevent mismatches.

Actually, the main issue here is to find the right syntax to define aliases for member. It's not as simple as it might sound, so any suggestion is welcome :-)

commented Dec 15, 2021 by thjungers (100 points)

Thanks for the fast reply!

This is fixed on the online server and with last snapshot.

It does work as intended on the example :-) For my more complex diagram, the correct members are linked, but the arrows are not always attached correctly: see this example.

(Sorry for the large example; I had trouble reducing it to a MWE as the entities then move to other places and the issue disappears)

For instance, in this example, arrows from members of entity G are badly placed: the arrow from C is in front of Hs, the one from Hs is in front of Ps and the ones for L and Ps are below the entity.

Actually, the main issue here is to find the right syntax to define aliases for member. It's not as simple as it might sound, so any suggestion is welcome :-)

I was thinking of using the same syntax as aliases for entities or classes : "Class name" as CN, but I don't know if it would be compatible with the current syntax for members.

commented Dec 15, 2021 by plantuml (295,000 points)

It does work as intended on the example :-) For my more complex diagram, the correct members are linked, but the arrows are not always attached correctly: see this example.

Thanks (again) for the feedback.

This is fixed (again) in last snapshot and on the online server

Tell us if you find other issues!

commented Dec 15, 2021 by thjungers (100 points)
This works wonderfully. Thanks!
commented Jan 6, 2023 by jlo2k (160 points)
Hello, the skinparam stil does produce erratic links still, i am not understanding the b-splines suggestion, but should we not talk to the graphviz developers to find a solution that would simply ensure the diagram will be consumable? The whole ability is not usable for me if I do not get a consumable diagram so I revert to draw them with draw.io or lucidchart, which s...

Kind regards
...