Skip to content

feat(joint-layout-elk): new package - ELK layout with container and port support - #3497

Open
Geliogabalus wants to merge 14 commits into
clientIO:masterfrom
Geliogabalus:layout-elk
Open

feat(joint-layout-elk): new package - ELK layout with container and port support#3497
Geliogabalus wants to merge 14 commits into
clientIO:masterfrom
Geliogabalus:layout-elk

Conversation

@Geliogabalus

Copy link
Copy Markdown
Contributor

Summary

Introduces @joint/layout-elk, a new package that lays out JointJS graphs using the Eclipse Layout Kernel (ELK) via elkjs, exposed as a single async layout(graph, options?) entry point.

  • Elements embedded in another element are laid out as a container - the parent is resized (and positioned) by ELK to fit its content, at any nesting depth. Cross-container links are filed under their lowest common ancestor per ELK's hierarchical-edge convention (elk.hierarchyHandling: INCLUDE_CHILDREN by default).
  • Ports route edges to/from the position JointJS itself already computes for them (elk.portConstraints: FIXED_POS); the new positionPorts option lets ELK reposition/reorder them instead, writing the computed position back onto the graph.
  • Per-cell escape hatches into ELK's option space: nodeOptions, portOptions and edgeOptions callbacks.
  • Two examples:
    • layout-elk-ts migrated to the new layout() entry point (previously hand-rolled ELK export/import).
    • layout-elk-containers-ports-ts (new) - a fixed, non-random diagram exercising containers, ports, per-node positionPorts, and a width-restricted layout (elk.aspectRatio + elk.layered.wrapping.strategy).

Test plan

  • yarn test in packages/joint-layout-elk - 10/10 passing
  • yarn lint in packages/joint-layout-elk - clean
  • tsc --noEmit for both examples - clean
  • Both examples built with webpack and visually verified in a headless browser (containers resize to fit content, ports render with correct labels/anchors, links route correctly within and across containers, positionPorts reorders ports on the opted-in nodes only, drawing wraps to stay within the 1000-unit width target)
  • yarn changeset status --since=upstream/master - reports @joint/layout-elk -> 0.2.0 (minor) with 4 changesets

…r-port ELK options

- Elements embedded in another element are laid out as a container -
  the parent is resized (and positioned) by ELK to fit its content, at
  any nesting depth. Cross-container links are filed under their
  lowest common ancestor per ELK's hierarchical-edge convention.
- Ports route edges to/from the position JointJS itself already
  computes for them (`elk.portConstraints: FIXED_POS`); the new
  `positionPorts` option lets ELK reposition/reorder them instead.
- Add a `portOptions` callback for per-port ELK layout options,
  alongside the existing `nodeOptions`/`edgeOptions`.
- Default to `elk.hierarchyHandling: INCLUDE_CHILDREN` so edges
  crossing a container's boundary are accounted for during layout.
- Migrate the `layout-elk-ts` example to the package's `layout()` entry
  point instead of hand-rolled ELK export/import.
A fixed (non-random) system diagram exercising the new @joint/layout-elk
capabilities: three containers, eight services connected through ports
(three of which opt into `positionPorts` so ELK orders them to minimize
crossings), and `elk.aspectRatio`/`elk.layered.wrapping.strategy` tuned
to keep the drawing within a soft 1000-unit width budget.
The package itself (README, build config, initial layout()) isn't
covered by an earlier changeset - this PR is its first appearance on
master, so the changelog should read as an introduction, not a bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant