Skip to content

(WIP) feat: add @joint/layout-msagl package #2898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

MartinKanera
Copy link
Contributor

@MartinKanera MartinKanera commented Mar 7, 2025

Description

The layout function arranges either an entire JointJS graph or a specified subset of cells using MSAGL. It converts the cells into MSAGL geometry and applies the Sugiyama layout algorithm with Rectilinear or SplineBundling edge routing.

Caveats

  • Elements containing embedded cells are treated as subgraphs. As a result, subgraphs are compressed to their minimal possible size, determined by the width and height of their child elements. This may cause parent elements to have dimensions different from their original size.
  • Layouting inside the subgraphs is set to TB - since any other settings seem to completely destroy the layout.

API

interface Options {
    layoutOptions?: {
        layerSeparation?: number,
        nodeSeparation?: number,
        layerDirection?: LayerDirectionEnum,
        gridSize?: number
    },
    edgeRoutingSettings?: {
        edgeRoutingMode?: EdgeRoutingMode
    },
    margins?: {
        left: number,
        right: number,
        top: number,
        bottom: number
    }
}
function layout(graphOrCells: dia.Graph | dia.Cell[], options?: Options): g.Rect {}

Label positioning for link relies on Link.attributes.labelSize as { width: number, height: number }.
The subgraph's dimensions are expanded to account for the label size, which can be set accordingly at Element.attributes.labelSize as { width: number, height: number }.

@MartinKanera MartinKanera self-assigned this Mar 7, 2025
@MartinKanera MartinKanera requested a review from kumilingus March 22, 2025 00:49
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