Component Diagrams: please add link direction/type token into the id of the corresponding SVG path

+1 vote
asked Aug 5, 2019 in Wanted features by boshka (3,940 points)
edited Aug 5, 2019 by boshka

Could you add link direction/type token into the id the corresponding path of the SVG output?

Here is the example:

@startuml
    component a as a {
    }
    component b as b {
    }

    a->b: test
@enduml

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuKhEpot8pqlDAr58L4Wi1XBLNBL8WaaWmIIm85UYhbsIbK99Qd49bqDgNWfGDm00

In the svg source, I would like to see the path tag with the following id: id="a->b"

instead of: id="a-b"

Also, if the link in .puml code is, say, "a -o b", the id in the svg should be "a-ob"

So, basically I propose to pick the link notation from .puml code and put it as is into the id of the corresponding path tag in the svg. Could this enhancement be added, please?

This will help identifying directions and arrow types (i.e. components relationships) directly from the SVG source

1 Answer

0 votes
answered Aug 6, 2019 by plantuml (295,000 points)
Ok, in last beta http://beta.plantuml.net/plantuml.jar we have changed the uid to id="a->b".

Is it working for you ?

We still have to manage "o" and other decoration.
commented Aug 6, 2019 by boshka (3,940 points)
edited Aug 6, 2019 by boshka

Thank you, however, it does work but NOT quite as expected. Please have a look at the attached image (I marked the issue with red on the image):

The B to A id looks wrong. It should be either "b->a" or "a<-b" AND not "a->b"

commented Aug 6, 2019 by plantuml (295,000 points)

Thanks for the screenshot, it really helps.

However, could you post your text diagram ?

It seems to work for us with:

@startuml
component a as a {
}
component b as b {
}
a->b: test1
b->a: test2
@enduml

Thanks!

commented Aug 6, 2019 by boshka (3,940 points)
edited Aug 6, 2019 by boshka

Thank you! Here is the real piece of code from that screenshot:

@startuml

title SVG Ids issue:

component "Comp A" as a {
!a_at_AtoB = "a"
!a_at_BtoA = "a"
}

component "Comp B" as b {
!b_at_AtoB = "b"
!b_at_BtoA = "b"
}

a_at_AtoB -->> b_at_AtoB: A to B
a_at_BtoA <<-- b_at_BtoA: B to A
@enduml

However, you don't really need it. Just correct your piece as follows and it will fail:

@startuml
component a as a {
}
component b as b {
}
a->b: test1
a<-b: test2
@enduml

On the latest beta you'll notice the second link id failing:

...
<!--link a to b-->

<path d="M54.2889,46.6475 C59.7682,49.2734 65.6878,51.6132 71.5,53 C84.9016,56.1977 89.0984,56.1977 102.5,53 C106.678,52.0032 110.911,50.5142 114.996,48.7804 " fill="none" id="a-&gt;b" style="stroke: #A80036; stroke-width: 1.0;"/>

...

<!--link a to b--> (really no matter since it is a comment, but should be <!--link b to a-->)

<path d="M59.324,32 C78.1065,32 102.1832,32 119.858,32 " fill="none" id="a-&gt;b-1" style="stroke: #A80036; stroke-width: 1.0;"/>
(should be "b&lt;-a...")
...
commented Aug 6, 2019 by plantuml (295,000 points)
Ok, thanks.

This should be fixed in last beta http://beta.plantuml.net/plantuml.jar

Note that there are probably other issue on those id, so you can post here when you'll find another one :-)
commented Aug 6, 2019 by boshka (3,940 points)
edited Aug 6, 2019 by boshka
yah, that works better, however, this still gives an ambiguity that I did not notice earlier:

since you can flip the components in the id, I cannot definitely tell apart if the direction is normal or reverse (for example, in terms of CSS animation).

So could we try not to flip the components but, instead, flip the arrow, that is:

for
"a<-b: test 2" in the pulml code example above could you do in the svg path:
id="a<-b" instead of id="b->a"?

In this way I will always know that "->" means normal direction for the SVG path and "<-" means reverse direction for the SVG path.
commented Aug 7, 2019 by plantuml (295,000 points)
Ok, this should be fixed in last beta http://beta.plantuml.net/plantuml.jar

Tell us if it's not working for you.
commented Aug 7, 2019 by boshka (3,940 points)
edited Aug 7, 2019 by boshka
Now it is better, but now it draws ">" even if the link is defined in puml without "<" or ">", such as:

a -- b

the id you'll get will be "a->b", while should be just "a-b"
commented Aug 7, 2019 by plantuml (295,000 points)
Ok thanks.

This is fixed in last beta http://beta.plantuml.net/plantuml.jar
commented Aug 7, 2019 by boshka (3,940 points)
Looks ok, now. I'll let you know if notice anything else.

BTW, how it will currently behave in case there is decoration other than < or >?

i guess for now it would be best to always map all others, like "-o" and "o-" etc. to "->" and "<-" correspondingly. What do you think?
commented Aug 7, 2019 by plantuml (295,000 points)
Right now we stick to -> and <- because it's easier for us, even for other decorations.

Just tell us if it's not ok for you. Thanks!
commented Aug 8, 2019 by boshka (3,940 points)
edited Aug 8, 2019 by boshka

ok, then, what I see currently, for example, for the following puml code:

a 0-[dashed]--0 b
or
a 0--0 b
or
a 0-0 b
or
a o-o b
etc. (and, probably, etc with other decorations)

there will be wrong direction info in the id:

id="a->b"

(should be just "a-b", since the above puml code examples mean it is a bidirectional link/relationship)

commented Aug 8, 2019 by plantuml (295,000 points)
Right, this is fixed in last beta http://beta.plantuml.net/plantuml.jar

Thanks for your tests!
commented Aug 8, 2019 by boshka (3,940 points)
Many thanks! Looks ok so far. Will let you know if I see something wrong.
...