Skip to content

mermaid


Function: createCommonLayoutRenderer()

createCommonLayoutRenderer<CoreResult, PreparedLayout, MeasureResult>(__namedParameters): (data4Layout, svg, helpers?, options?) => Promise<void>

Defined in: packages/mermaid/src/rendering-util/layout-algorithms/common/index.ts:107

Type Parameters

CoreResult

CoreResult = unknown

PreparedLayout

PreparedLayout = void

MeasureResult

MeasureResult = { graph: Graph; groups: { clusters: D3Selection<SVGGElement>; edgeLabels: D3Selection<SVGGElement>; edgePaths: D3Selection<SVGGElement>; nodes: D3Selection<SVGGElement>; rootGroups: D3Selection<SVGGElement>; }; nodeElements: Map<string, D3Selection<SVGElement | SVGGElement>>; }

Parameters

__namedParameters

CommonLayoutRendererDefinition<CoreResult, PreparedLayout, MeasureResult>

Returns

(data4Layout, svg, helpers?, options?): Promise<void>

Parameters

data4Layout

LayoutData

svg

SVG

helpers?

common

{ evaluate: (val?) => boolean; getMax: (...values) => number; getMin: (...values) => number; getRows: (s?) => string[]; getUrl: (useAbsolute) => string; hasBreaks: (text) => boolean; lineBreakRegex: RegExp; removeScript: (txt) => string; sanitizeText: (text, config) => string; sanitizeTextOrArray: (a, config) => string | string[]; splitBreaks: (text) => string[]; }

common.evaluate

(val?) => boolean

Converts a string/boolean into a boolean

common.getMax

(...values) => number

Wrapper around Math.max which removes non-numeric values Returns the larger of a set of supplied numeric expressions.

common.getMin

(...values) => number

Wrapper around Math.min which removes non-numeric values Returns the smaller of a set of supplied numeric expressions.

common.getRows

(s?) => string[]

Gets the rows of lines in a string

common.getUrl

(useAbsolute) => string

Gets the current URL

common.hasBreaks

(text) => boolean

Whether or not a text has any line breaks

common.lineBreakRegex

RegExp

common.removeScript

(txt) => string

Removes script tags from a text

common.sanitizeText

(text, config) => string

common.sanitizeTextOrArray

(a, config) => string | string[]

common.splitBreaks

(text) => string[]

Splits on
tags

getConfig

() => MermaidConfig

getConfig

FunctionDescriptionTypeReturn Values
getConfigObtains the currentConfigGet RequestAny Values from current Config

Notes: Avoid calling this function repeatedly. Instead, store the result in a variable and use it, and pass it down to function calls.

insertCluster

(elem, node) => Promise<any>

insertEdge

(elem, edge, clusterDb, diagramType, startNode, endNode, diagramId, skipIntersect) => object

insertEdgeLabel

(elem, edge) => Promise<SVGGElement>

insertMarkers

(elem, markerArray, type, id) => void

insertNode

(elem, node, renderOptions) => Promise<Selection<SVGGElement, unknown, Element | null, unknown> | D3Selection<SVGAElement>>

interpolateToCurve

(interpolate, defaultCurve) => CurveFactory

labelHelper

<T>(parent, node, _classes?) => Promise<{ bbox: DOMRect; halfPadding: number; label: Selection<SVGGElement, unknown, Element | null, unknown>; shapeSvg: Selection<SVGGElement, unknown, Element | null, unknown>; }>

log

Record<LogLevel, {(...data): void; (message?, ...optionalParams): void; }>

positionEdgeLabel

(edge, paths) => void

options?

RenderOptions

Returns

Promise<void>

Opens in mermaid.ai