Skip to content

Conversation

@kirchsth
Copy link
Member

implementation of #247

This fix produces the correct dynamic legend if

  • person sprites are defined via SHOW_PERSON_SPRITE() and other PERSON related layout calls
  • multiple UpdateElementStyle() defines the same element type (missing parameters a reused from last call)
  • Add....Tag() calls reused the UpdateElementStyle() parameters
    (e.g. if an UpdateElementStyle("external_system", ....) calls defines a new background color, a following AddExternalSystemTag() call reused automatically the new defined background color too)
  • (C4Version() is updated to *.beta2)

(the sample is logically not useful, but it should show all fixes)

@startuml
!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Component.puml

' person legend displays the correct sprite
SHOW_PERSON_SPRITE(person2)

UpdateElementStyle("external_system", $bgColor="chocolate", $fontColor="orange", $borderColor="orange", $shadowing="true", $shape=RoundedBoxShape(), $sprite="robot", $techn="my tech", $legendSprite="robot,scale=0.25")

' missing definitions are reused from last UpdateElementStyle() in legends too
UpdateElementStyle("external_system", $sprite="robot2", $legendSprite="robot2,scale=0.25", $legendText="Robot (external)")

' missing definitions are reused from last UpdateElementStyle() in legends too
AddExternalSystemTag("micro_service", $shape=EightSidedShape(), $legendText="Micro service (external)")

'generic tag does not reuse other styles (in legend it has no text color,...)
AddElementTag("storage", $shadowing="false", $shape=RoundedBoxShape())

Person(person, "Person")
System_Ext(system, "System")
System_Ext(system1A, "System 1A", $tags="micro_service")
System(storage, "Storage", $tags = "storage")

SHOW_LEGEND(false)
@enduml

It can be tested with my extended branch

BR Helmut

@kirchsth kirchsth marked this pull request as ready for review October 23, 2022 14:01
@kirchsth kirchsth added this to the v2.5.0 milestone Oct 23, 2022
@kirchsth kirchsth requested a review from Potherca October 23, 2022 14:02
@Potherca
Copy link
Member

Should we add a Percy test for the legend?

@kirchsth
Copy link
Member Author

The commit contains the update percy test TestLegend.puml.
I would not add a second one (as long we do not check the generated output file (e.g. svg) at all; but this could be another issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Colors have to be defined in UpdateElementStyle() too, otherwise error in dynamic legend

2 participants