plantuml-stdlib / C4-PlantUML

C4-PlantUML combines the benefits of PlantUML and the C4 model for providing a simple way of describing and communicate software architectures
MIT License
6.42k stars 1.11k forks source link

Line styling not recognized when using ELK #340

Closed StephanPirnbaum closed 5 months ago

StephanPirnbaum commented 9 months ago

I'm using C4-PlantUML with ELK, as it regularly produces better outputs. However, I ran into an issue when using e.g. lineColor or lineStyle.

In the following example, the relation defined using standard PlantUML syntax is correctly rendered, whereas using the C4-PlantUML it is not.

@startuml
!include <C4/C4_Component>
!pragma layout elk

AddRelTag("DEF", $legendText="Java-Abhängigkeit", $lineColor = "#blue", $lineStyle = DottedLine())

Component(A, "A")

Component(B, "B")

A -[#orange,dashed]-> B

Rel(A, B, "Test", $tags="DEF")
@enduml

This leads me to the conclusion that ELK itself has no issues with styling lines (which would have had me wonder, tbh).

When not using ELK, the example is working, however.

@startuml
!include <C4/C4_Component>

AddRelTag("DEF", $legendText="Java-Abhängigkeit", $lineColor = "#blue", $lineStyle = DottedLine())

Component(A, "A")

Component(B, "B")

A -[#orange,dashed]-> B

Rel(A, B, "Test", $tags="DEF")
@enduml

For me, that looks like an issue of the combination C4-PlantUML syntax and ELK.

kirchsth commented 9 months ago

Hi @StephanPirnbaum,

thank you for the finding, but I think your conclusion is wrong. I think it is elk related, I can reproduce the problem without C4 too. Samples see below.

I entered a bug in the PlantUML forum

BR Helmut

StephanPirnbaum commented 9 months ago

Hi @kirchsth

thank you for the fast investigation and reply. You're right, I was not considering using skinparam which would explain the difference to my example. I can confirm your conclusion.

kirchsth commented 5 months ago

Hi @StephanPirnbaum,

the last PlantUML beta has a first fix: line color, thickness and style are correct (details see PlantUML PR - Elk: Allow full style on arrows (except fontcolor).

You can download a *.jar file from PlantUML Releases-snapshot - Assets section (I tested it with `plantuml-mit-SNAPSHOT.jar).

The $fontcolor is not correct supported, but if you use $textColor = $ARROW_FONT_COLOR then the legend uses the same $fontColor as the diagram itself.

e.g. following source

@startuml
!theme C4_united from <C4/themes>
!include <C4/C4_Component>
!pragma layout elk
'!pragma layout smetana

'known issue: $textColor is not working with elk/smetana
' AddRelTag("DEF", $legendText="Java-Abhängigkeit", $textColor = "#green", $lineColor = "#blue", $lineStyle = DottedLine(), $lineThickness=7)
' AddRelTag("DEF", $textColor = "#green", $lineColor = "#blue", $lineStyle = DottedLine(), $lineThickness=7)

' $textColor is not working, but if the unchanged color is defined then the legend displays the correct color again
AddRelTag("DEF", $textColor = $ARROW_FONT_COLOR, $lineColor = "#blue", $lineStyle = DottedLine(), $lineThickness=7)

Component(A, "A")
Component(B, "B")
A -[#orange,dashed]-> B
' WithoutPropertyHeader()
AddProperty("PropC1", "ValueC1")
AddProperty("PropC2", "ValueC2")
Rel(A, B, "Te<$person>st", $tags="DEF")

SHOW_LEGEND()
@enduml

produces following output

image

Can you please check the fix with your diagrams too?

Thank you and BR Helmut

StephanPirnbaum commented 5 months ago

Hi @kirchsth

thanks for your work. The provided Snapshot resolved the issue for me.

Best Stephan

kirchsth commented 5 months ago

Hi @StephanPirnbaum,

@arnaudroques create a fix for $fontColor too (details see https://github.com/plantuml/plantuml/issues/1834) that the newest snapshot supports $fontColor too.

@startuml
!theme C4_united from <C4/themes>
!include <C4/C4_Component>
!pragma layout elk
'!pragma layout smetana

' $textColor is working
AddRelTag("DEF", $textColor = "#green", $lineColor = "#blue", $lineStyle = DottedLine(), $lineThickness=7)
' combined stereotypes/tags are working too
AddRelTag("DEF2",$lineColor = "#red")

Component(A, "A")
Component(B, "B")
A -[#orange,dashed]-> B
' WithoutPropertyHeader()
AddProperty("PropC1", "ValueC1")
AddProperty("PropC2", "ValueC2")
Rel(A, B, "Te<$person>st", $tags="DEF2+DEF")

SHOW_LEGEND()
@enduml

image

BR Helmut