How to hide participants not on current page?

0 votes
asked Oct 17, 2021 in Wanted features by dragondive (1,360 points)
recategorized Oct 19, 2021 by dragondive

I want to parse a JSON file to generate multiple diagrams. These have roughly the same structure, but some portions are configurable. But this doesn't appear possible as all the pages include all the participants, and not only the ones on that page. 

Below is my MVCE:

@startuml

!$people_data = {
    "group_list" : [
        {"first": "Alice", "second": "Bob"},
        {"first": "Charlie", "second": "David"}
    ]
}

!foreach $group in $people_data.group_list
    newpage
    hide unlinked
    $group.first -> $group.second : Hello
!endfor

@enduml

I get three diagrams and they contain all the participants, not only the ones appearing on that page. How to fix this problem so that the diagrams corresponding to each item in the JSON data is independent of others?

While I could live with the extra "empty" diagram, it would be good if that can be fixed as well.

 

commented Oct 17, 2021 by dragondive (1,360 points)
By the way, how to add images in the question? I tried uploading the images to imgBB and including the link in "Image Info", but that doesn't seem to work.

https://ibb.co/s9hWhDN
https://ibb.co/5xXDJjR
https://ibb.co/3Cx9Jkf
commented Oct 17, 2021 by The-Lu (70,400 points)

Hello D.,

See similar defect here:


And to avoid first empty diagram, you can put 'newpage' at the end as:

!foreach $group in $people_data.group_list
    hide unlinked
    $group.first -> $group.second : Hello
    newpage
!endfor

Regards.

commented Oct 17, 2021 by The-Lu (70,400 points)

And (for PlantUML team) here is a minimal example of those defects:

@startuml
hide unlinked
a->b

newpage

hide unlinked
c->d
@enduml

Regards.

commented Oct 19, 2021 by dragondive (1,360 points)

Hello Th.
Thank you for taking the time to respond. I have now changed the category to wanted features. Your suggestion to place newpage at the end is a good one. Unfortunately, it doesn't work for my "real" usecase. There I have to generate multiple diagrams within one iteration and also specify a title for each diagram. Putting newpage at the end causes the titles to get mixed up in a strange manner. 

The actual loop is more like this:

!foreach $item in $list
    newpage title for diagram-A here
    ' diagram-A code here

    newpage title for diagram-B here
    ' diagram-B code here

    newpage title for diagram-C here
    ' diagram-C code here
!endfor

1 Answer

0 votes
answered Dec 4, 2021 by emalware (280 points)
the keyword hide unlinked does not seem to work
...