Skip to content

Options

The second argument of layout(input, options) and engine.layout(input, options). The defaults of an engine (createEngine({ defaults })) come first, and the options of one call replace them.

OptionTypeDefaultMeaning
spacingnumber24The base distance in pixels. The default gap and padding of each container come from it.
nodeSize{ width, height }120 × 48The size of a leaf with no size in its spec.
headernumber24The smallest space above the content of a nested container, for its label. The padding counts as a part of it.
routerstring"straight"The router of the edges: straight, orthogonal, avoid or a router that you register.
treeEdges"linked", "all", "none""linked"The tree edges of the output. See edges.
origin{ x, y }{ x: 0, y: 0 }The top-left corner of the root box.
measure(node) => size or undefinednoneThe size of a leaf. Use it to measure the labels.
auditbooleantrueWith false, the engine does not examine the layout. It is a little faster.
strictbooleanfalseWith true, the engine throws an IrekoError for each finding with the severity error.
trace(event) => voidnoneA function that gets the output of each phase. See the pipeline.

The input is { root, edges }. The root and each child is a NodeSpec.

FieldTypeDefaultMeaning
idstringnone, give oneThe identifier. Each node of a tree has a different identifier.
labelstringthe idThe text that a renderer shows.
layoutstring or { type, ...options }"grid"The strategy that arranges the children, with its options.
mode"linked", "nested""linked"Where the children go: around the box, or inside it.
fit"grow", "scale", "clip""grow"The policy of a nested container with a size. See fit.
size{ width?, height? }nodeSizeThe size of a leaf, or the smallest size of a container.
childrenNodeSpec[]noneThe children.
dataanynoneYour data. The engine copies it to the output, and does not read it.
FieldTypeDefaultMeaning
source, targetstringnone, give themThe identifiers of two nodes of the tree.
idstringedge-NThe identifier. N is the place of the edge in the list, from 0.
labelstringnoneThe text at the middle of the route.
dataanynoneYour data. The engine copies it to the output.

Each strategy has these options too. The engine reads them.

OptionTypeDefaultMeaning
gapnumber, 0 or morespacingThe distance between two children.
paddingnumber, 0 or morespacingThe space inside the edge of a nested container.
headernumber, 0 or morethe header optionThe smallest space above the content of a nested container.
The options of the strategy grid
OptionTypeDefaultDescription
columnsinteger (0 or more)0The number of columns. With 0, the nested mode makes an approximately square grid, and the linked mode makes one row.
justify"start" | "center" | "end""center"The horizontal place of a child in its cell.
align"auto" | "start" | "center" | "end""auto"The vertical place of a child in its cell. With auto, linked children align at the top, and nested children at the center.
uniformbooleanfalseIf true, all cells have the size of the largest cell.
side"bottom" | "top" | "left" | "right""bottom"In the linked mode, the side of the node where the children go.
distancenumber (0 or more)0In the linked mode, the distance between the node and its children. The value 0 means 1.5 times the gap.
The options of the strategy radial
OptionTypeDefaultDescription
startAnglenumber (-360 to 360)-90The angle of the first child, in degrees. The value 0 is to the right, and -90 is at the top.
sweepnumber (1 to 360)360The angle of the arc that holds the children, in degrees. The value 360 is a full ring.
clockwisebooleantrueIf true, the children follow the clockwise direction on the screen.
distancenumber (0 or more)0In the linked mode, the smallest distance between the node and the circle of a child. The value 0 means the gap.
The options of the strategy tree
OptionTypeDefaultDescription
side"bottom" | "top" | "left" | "right""bottom"The side of the node where the children go.
distancenumber (0 or more)0The distance between the node and its children. The value 0 means 1.5 times the gap.
align"center" | "start" | "end""center"The place of the node along the row of its children: over the middle, the first child or the last child.
The options of the strategy layers
OptionTypeDefaultDescription
side"bottom" | "top" | "left" | "right""bottom"The side where the edges go: the first layer is on the other side.
distancenumber (0 or more)0The distance between two layers. The value 0 means 2 times the gap.
align"center" | "start" | "end""center"The place of a layer across the direction of the edges: at the start, at the middle or at the end.

createEngine(config) and engine.extend(config):

FieldTypeMeaning
strategiesStrategy[]More strategies. A strategy with the type of a built-in strategy replaces it.
routersRouter[]More routers. A router with the type of a built-in router replaces it.
defaultsLayoutOptionsThe default options of each layout of this engine.
limits{ maxNodes?, maxDepth?, maxChildren? }The limits. The defaults are 100000, 10000 and 10000.

mountSvg, mountDom, mountCanvas and <LayoutView>:

OptionTypeDefaultMeaning
themePartial<Theme>lightThemeThe colors and the fonts.
viewportViewporta new viewportThe pan and the zoom. Share one to move two views together.
interactivebooleantruePan with the pointer, zoom with the wheel.
durationnumber320The time of the animation, in milliseconds.
fitbooleantrueThe first layout fills the element.

<LayoutView> also has layout, renderer ("svg", "dom" or "canvas"), selected, onPick, className and style.

OptionTypeDefaultMeaning
themePartial<Theme>lightThemeThe colors and the fonts.
paddingnumber16The space around the layout.
titlestringnoneThe title of the image, for assistive technology.
labelsbooleantrueWith false, the output has no text.
backgroundbooleantrueWith false, the output has no background rectangle.
FieldLightMeaning
background, nodeFill, nodeStrokecolorsThe page and the boxes.
containerFill, containerStrokecolorsThe nested containers.
text, mutedTextcolorsThe labels of boxes, and the labels of containers and edges.
edge, extraEdgecolorsThe tree edges, and the extra edges (dashed).
accentcolorThe selected boxes.
radius, fontSize, fontFamilynumbers, fontThe corners and the text.

lightTheme, darkTheme and themeOf(partial, base) are in ireko/render.

parse(text, { strategies }) and print(input, { strategies, width }):

OptionDefaultMeaning
strategiesBUILTIN_STRATEGY_NAMES: grid, radial, tree and layersThe names of the strategies. Give the names of the strategies that you register.
width (print)80The largest length of a line of leaves.

All layout options, and rootLayout, nodeSpec, hierarchy, engine and edgeType. Refer to the React Flow guide.