How to collapse a horizontal region of a manually laid-out diagram (like hiding columns in Excel)?

We build value stream maps with GoJS 3.1.10. The diagrams are long horizontal chains of process nodes with data boxes, inventory nodes and material/information flow links. Node positions are manual: `location` is two-way bound to a `loc` string in the model, and `Diagram.layout` is the default `go.Layout`. Users run an automatic layout on demand only.

Some maps are very wide. We want to give users a way to simplify the overview by collapsing a
user-selected horizontal region of the diagram, similar to hiding a range of columns in Excel:

  • All parts inside an x-range [x1, x2] are hidden.
  • Everything right of x2 moves left by x2 - x1, so no gap remains.
  • A small marker at the seam (for example “… 5 processes hidden …”) lets the user expand the region again.
  • Links that cross the region, from a visible node left of it to a visible node right of it, stay visible and re-route.
  • Expanding restores the exact original positions. The stored `loc` values in the model should
    not change while a region is collapsed, because the model is saved and synchronised between users, and this is a view-only state.

We have looked at `Part.visible`, group collapsing with `isSubGraphExpanded` and `Placeholder`, and tree collapsing with `isTreeExpanded`, but none of them seems to cover hiding a middle section of a chain in a diagram without an automatic layout.

How would you approach this in GoJS? Is there a built-in mechanism or a sample that we have overlooked, or what would be the recommended way to implement it?

Thanks in advance.

Do you have an automatic (or isOngoing) layout running, generally?

There’s no built-in way to do this, but it’s not unreasonable to toggle visibility on a range and move everything from the right side over. We don’t have a way to do this automatically, but

Unless the ranges are well-defined beforehand, I wouldn’t use Groups (subgraphs) to do this. I’d just hide them, recording the range, and moving everything. But if you don’t disable ongoing layouts, you may have trouble.

For finding everything in the range, you could use Diagram.findObjectsIn with partial inclusion set to true or false. Then in a transaction: hide that collection (loop over and set visible to false on each node), and then shift everything to the right (loop nodes shift if node.actualBounds.x is greater than x2) in the same transaction.

I don’t think there’s much more to it, presuming layouts aren’t involved. There are also considerations when it comes time to un-hide, of course.

Thanks, Simon. No, there is no automatic or ongoing layout. The diagram uses the default go.Layout.

One constraint we have: node locations are TwoWay-bound to the model, and the model is saved
and synchronised. So we do the shift as a view transform in the location (and link points)
binding converters instead of moving the nodes. A prototype of that works. We will use
findObjectsIn for selecting the parts in the range.

It really depends on how temporary or not you want to treat this collapsed state, and what users are allowed to do while things are collapsed, but you might want to record true locations, plus any shift offset (if nothing were collapsed), instead of doing any view transform. Unless what I’m describing is exactly what you mean.