Collapsible and expandable containers
This is a feature request or idea I hope will be considered for D2 at some point.
The Block Diagram Language in Msc-generator has a useful feature that allows blocks containing child blocks to be collapsed.
Collapsing a container shape would hide the shapes contained in it, and additionally "fold" lines connected to child shapes to a single line connecting the parent instead. The objective is to reduce a diagram's visual noise.
- Container shapes can be set to support collapsibility or not (e.g.
collapsible: true). - They can also be set to a collapsed or expanded state initially, so the initial state of the diagram can be specified (e.g.
collapsed: true). - Collapsing and expanding is done interactively via clicking an arrow (or a different symbol) displayed e.g. at a fixed position in the top right corner of a container shape.
- Interactive behavior is only supported for interactive formats such as SVG.
- Rendered formats (e.g. PNG) that don't allow interactivity, display a diagram using the initial configured collapsed/expanded state and don't display UI elements to expand or collapse.
- Optionally, when rendering a diagram to a non-interactive format, the user can specify (in ways supported by extensions and CLI) that all qualifying shapes need to be collapsed or expanded.
One use case is the presentation of an architecture sketch, where the presenter can gradually introduce the audience to more detail by explaining the high-level concepts first based on the collapsed state, and then expanding and explaining the detailed parts of the diagram one by one.