The "TreeExpanderButton", which changes the Node.isTreeExpanded property, really only works with tree structures. When you want to hide/show the "downstream" nodes from a given node, using the "TreeExpanderButton" might not do what you like, especially when there are cycles in the graph structure.

Instead, this sample implements a "Button" with custom behavior to modify the visibility of each Node. If this behavior is still not quite right for your app, you can adapt the behavior implemented in the collapseFrom and expandFrom functions to use different criteria for when to stop recursion.


GoJS Features in this sample

Layered Digraph Layout

This predefined layout is used for placing Nodes of a general directed graph in layers (rows or columns). This is more general than TreeLayout, as it does not require that the graph be tree-structured. More information can be found in the GoJS Intro.

Related samples


Buttons

GoJS defines several Panels for common uses. These include "Button", "TreeExpanderButton", "SubGraphExpanderButton", "PanelExpanderButton", "ContextMenuButton", and "CheckBoxButton". "ContextMenuButton"s are typically used inside of "ContextMenu" Panels; "CheckBoxButton"s are used in the implementation of "CheckBox" Panels.

These predefined panels can be used as if they were Panel-derived classes in calls to GraphObject.make. They are implemented as simple visual trees of GraphObjects in Panels, with pre-set properties and event handlers.

More information can be found in the GoJS Intro.

Related samples