collab/mermaid/packages/mermaid-layout-tidy-tree/src/index.tsblame
View source
6dd74de1/**
6dd74de2 * Bidirectional Tidy-Tree Layout Algorithm for Generic Diagrams
6dd74de3 *
6dd74de4 * This module provides a layout algorithm implementation using the
6dd74de5 * non-layered-tidy-tree-layout algorithm for positioning nodes and edges
6dd74de6 * in tree structures with a bidirectional approach.
6dd74de7 *
6dd74de8 * The algorithm creates two separate trees that grow horizontally in opposite
6dd74de9 * directions from a central root node:
6dd74de10 * - Left tree: grows horizontally to the left (children alternate: 1st, 3rd, 5th...)
6dd74de11 * - Right tree: grows horizontally to the right (children alternate: 2nd, 4th, 6th...)
6dd74de12 *
6dd74de13 * This creates a balanced, symmetric layout that is ideal for mindmaps,
6dd74de14 * organizational charts, and other tree-based diagrams.
6dd74de15 *
6dd74de16 * The algorithm follows the unified rendering pattern and can be used
6dd74de17 * by any diagram type that provides compatible LayoutData.
6dd74de18 */
6dd74de19
6dd74de20/**
6dd74de21 * Render function for the bidirectional tidy-tree layout algorithm
6dd74de22 *
6dd74de23 * This function follows the unified rendering pattern used by all layout algorithms.
6dd74de24 * It takes LayoutData, inserts nodes into DOM, runs the bidirectional tidy-tree layout algorithm,
6dd74de25 * and renders the positioned elements to the SVG.
6dd74de26 *
6dd74de27 * Features:
6dd74de28 * - Alternates root children between left and right trees
6dd74de29 * - Left tree grows horizontally to the left (rotated 90° counterclockwise)
6dd74de30 * - Right tree grows horizontally to the right (rotated 90° clockwise)
6dd74de31 * - Uses tidy-tree algorithm for optimal spacing within each tree
6dd74de32 * - Creates symmetric, balanced layouts
6dd74de33 * - Maintains proper edge connections between all nodes
6dd74de34 *
6dd74de35 * Layout Structure:
6dd74de36 * ```
6dd74de37 * [Child 3] ← [Child 1] ← [Root] → [Child 2] → [Child 4]
6dd74de38 * ↓ ↓ ↓ ↓
6dd74de39 * [GrandChild] [GrandChild] [GrandChild] [GrandChild]
6dd74de40 * ```
6dd74de41 *
6dd74de42 * @param layoutData - Layout data containing nodes, edges, and configuration
6dd74de43 * @param svg - SVG element to render to
6dd74de44 * @param helpers - Internal helper functions for rendering
6dd74de45 * @param options - Rendering options
6dd74de46 */
6dd74de47export { default } from './layouts.js';
6dd74de48export * from './types.js';
6dd74de49export * from './layout.js';
6dd74de50export { render } from './render.js';