- I
- I
Remarks
Layout Style
The arrangement of components can be customized through various styles. Most styles, except NONE and KEEP_CENTERS, ensure that components are placed without overlapping. These styles allow for flexible and clear visual arrangements of subgraphs.
Concept
ComponentLayout is a ILayoutStage that can wrap and work with another ILayoutAlgorithm. This enables support for disconnected graphs by applying the layout algorithm to each component (subgraph) individually. The wrapped coreLayout handles each component's internal arrangement.
The general process followed by ComponentLayout includes:
- Identify the connected components within the graph.
- Temporarily hide all components of the graph.
- For each component:
- Unhide the component.
- Apply the coreLayout to arrange the component.
- Hide the component again.
- Unhide all components after processing.
- If a style other than NONE is specified, arrange the components in the layout space.
- Compute routes for edges that connect nodes from different components. The routing of these "inter-edges" can be customized via the interEdgeRouter property.
Features
To arrange the subgraphs of the components, ComponentLayout uses mappings defined by the componentLayouts, which can specify a distinct ILayoutAlgorithm for each component. If no specific algorithm is assigned, the coreLayout is used. If the core layout is not specified, components maintain their existing locations while being arranged spatially.
Grouped graphs are treated specially. All contents of a group node remain part of the same component as the group itself, ensuring internal consistency. To alter this behavior, grouping can be disabled via the considerGrouping property.
By default, components correspond to connected nodes in the graph. Custom subgraphs can be defined by assigning component IDs to nodes using the layout data property componentIds.
Node types, as defined by nodeTypes, can also be used to influence the arrangement. If all nodes in a component share the same node type, the component is classified under that type. Components of the same type are typically positioned near each other, but only certain styles — such as ROWS, SINGLE_ROW, SINGLE_COLUMN, and MULTI_ROWS_TYPE_SEPARATED — actively prioritize type-based ordering. Other styles focus on different criteria, such as compactness, and may not guarantee proximity of similar types.
Default Values of Properties
| Name | Default | Description |
|---|---|---|
| componentSpacing | 45 | |
| considerGrouping | true | Grouping information is considered for determining the components. |
| coreLayout | null | |
| edgeLabelPlacement | BasicEdgeLabelPlacement.CONSIDER | Edge labels are considered |
| gridSpacing | 0 | No grid is considered. |
| interEdgeRouter | null | Edges are routed as straight lines from source to target. |
| nodeLabelPlacement | BasicNodeLabelPlacement.CONSIDER | Node labels are considered |
| preferredSize | Size | Both preferred width and height are 400. |
| style | ComponentArrangementStyle.ROWS |
See Also
Developer's Guide
Members
Constructors
Initializes a new instance of the ComponentLayout class with an optional coreLayout.
Parameters
- coreLayout?: ILayoutAlgorithm
- The core layout algorithm to be used for arranging the layout. If
null, the default behavior is to keep the component subgraphs' locations unchanged unless specified otherwise by the componentLayouts.
Properties
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the spacing is negative
Default Value
Sample Graphs
45See Also
Developer's Guide
Property Value
true if the nesting structure of the graph is considered when determining the components, false otherwiseDefault Value
Sample Graphs
falseSee Also
Developer's Guide
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Property Value
Default Value
Defined in
LayoutStageBase.coreLayoutGets or sets whether to take node and edge labels into account when calculating the bounds of the graph components.
Property Value
Default Value
Sample Graphs
See Also
Developer's Guide
API
- EdgeLabelPreferredPlacement
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.
By default, when constructed, stages should be enabled. Users may disable a stage's functionality by setting this property to false.
Stages that can guarantee that the graph will not change can choose to not even execute the coreLayout when disabled.
Defined in
LayoutStageBase.enabledtrue, the layout will maintain the positions of components relative to each other in the context of the selected style, otherwise the order of the components can be changed during the component arrangement.Default Value
See Also
API
- style
Components will be moved by multiples of this value, thus keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid. The grid spacing also influences the distance between the components.
The spacing needs to be a non-negative value. If the grid spacing is set to 0, the grid won't be considered at all.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the given spacing is negative
Default Value
Sample Graphs
See Also
Developer's Guide
Gets or sets the current edge routing algorithm for handling inter-edges between different components, which may exist when customizing the component assignment using custom componentIds
Property Value
Default Value
Gets or sets whether to take node labels into account when calculating the bounds of the graph components.
Property Value
Default Value
Sample Graphs
See Also
Developer's Guide
Gets or sets the preferred size of the layout.
The layout size also defines the desired aspect ratio (width/height).
The width and height need to be greater than zero.
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the specified width or height is negative or zero or the given dimension is
null
Default Value
400.Sample Graphs
100x400Gets or sets how the components are arranged.
Property Value
Default Value
See Also
Developer's Guide
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Parameters
- graph: LayoutGraph
- The graph to apply the layout to.
Defined in
LayoutStageBase.applyLayoutDelegates the layout calculation for each component separately to the coreLayout and optionally arranges the components.
Produces a component graph layout.
This method is called by applyLayoutImpl in case style is set to another value than NONE.
It moves the components such that their bounds do not overlap.
Subclasses may want to override this method to introduce custom component arrangement styles. This involves calculating a new position for each component and moving them accordingly. You can use setComponentLocation to move a component with all of its elements, including nodes, edges, and labels to the new location.
Parameters
- graph: LayoutGraph
- the input graph
- components: SubgraphComponent[]
- the components (subgraphs) of the input graph
See Also
Calculates the bounds of a graph component including node margins.
Parameters
- graph: LayoutGraph
- the subgraph containing the nodes and edges of a component
Return Value
- Rect
- the bounds of the component
See Also
createLayoutData
(graph: LayoutGraph): ComponentLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the ComponentLayout.
createLayoutData
(graph: LayoutGraph): ComponentLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Parameters
- graph: LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Return Value
- ComponentLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given ComponentLayout.
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the ComponentLayout.
LayoutExecutor type is available at runtime.Parameters
- graph?: IGraph
- the graph that determines the generic type arguments of the created layout data
Return Value
- ComponentLayoutData<INode, IEdge, ILabel, ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given ComponentLayout.
Determines which nodes belong to the same graph component.
This implementation uses the graph connectivity to sort the nodes into different components. Nodes that are not connected by a path will be in separate components.
This method is called by applyLayoutImpl. It may be overridden to choose another approach to find components that will be passed to the coreLayout. However, most of the layout algorithms cannot handle disconnected graphs. Also, edges between custom components will be ignored.
Parameters
- graph: LayoutGraph
- the input graph
- compNumber: IMapper<LayoutNode, number>
- an IMapper<K, V> that will be filled with the zero-based index of the component to which the node belongs
Return Value
- number
- the number of connected components of this graph
See Also
Moves the top-left corner of the subgraph containing the specified nodes and edges to the given location.
Parameters
- graph: LayoutGraph
- The graph containing the component to be moved.
- component: SubgraphComponent
- The component (subgraph) consisting of the nodes and edges that should be repositioned.
- location: Point
- The new top-left location to which the subgraph should be moved.