pivotick / GraphUI / LegendOptions
Interface: LegendOptions
Defined in: interfaces/GraphUI.ts:668
UI.legend — the canvas legend. It is descriptive: it reports the colours the renderer already resolved and never assigns one, so the consumer stays the sole owner of node colouring.
Entries come from key (derived from the data, swatches sampled from the renderer), from entries (declared), or from both — key then supplies the default predicate for entries that don't carry one.
With neither, the legend keys itself on render.nodeTypeAccessor (the dimension you already declared for nodeStyleMap) — but only after checking that this dimension really is the colour dimension: every category must resolve to exactly one colour, there must be at least two of them, and few enough of them to be categories. That check is what makes a legend nobody asked for safe; UI.legend: true skips it, false suppresses the legend entirely.
To key a graph on more than one dimension at a time, pass LegendGroupOptions instead.
Shown in full and light modes only.
Example
UI: { legend: { key: 'type', title: 'Node type' } }Extends
Properties
collapsed?
optionalcollapsed:boolean
Defined in: interfaces/GraphUI.ts:626
Start collapsed.
Default
falseInherited from
collapsible?
optionalcollapsible:boolean
Defined in: interfaces/GraphUI.ts:624
Default
trueInherited from
enabled?
optionalenabled:boolean
Defined in: interfaces/GraphUI.ts:586
Default
true when the block is presentInherited from
entries?
optionalentries:LegendEntry[] | (graph) =>LegendEntry[]
Defined in: interfaces/GraphUI.ts:622
Declared entries, or a function re-resolved against the live graph every time the legend rebuilds (so the list can follow the data).
Inherited from
filterable?
optionalfilterable:boolean
Defined in: interfaces/GraphUI.ts:630
Clicking an entry filters the graph. false renders a pure key.
Default
trueInherited from
highlightOnHover?
optionalhighlightOnHover:boolean
Defined in: interfaces/GraphUI.ts:637
Hovering an entry reads its category off the canvas: the elements it stands for keep their look, everything else dims until the pointer leaves. Works on a filterable: false key too — pointing at a category asks nothing of the graph.
Default
trueInherited from
LegendSection.highlightOnHover
id?
optionalid:string
Defined in: interfaces/GraphUI.ts:605
Stable identity: the section's own filter key (__legend:<id>) and the section field of the legendToggle event.
Default
key, else section-<index>
Inherited from
key?
optionalkey:string
Defined in: interfaces/GraphUI.ts:617
Derived mode: the data key whose distinct values become the entries, each swatch sampled from the renderer's resolved style. Read off nodes, or off edges when scope is 'edge'. Also supplies the default predicate when entries are declared without one.
Inherited from
maxVisibleEntries?
optionalmaxVisibleEntries:number
Defined in: interfaces/GraphUI.ts:639
Entries shown before the list scrolls.
Default
12Inherited from
LegendSection.maxVisibleEntries
position?
optionalposition:LegendPosition
Defined in: interfaces/GraphUI.ts:675
Which corner it docks in. In full mode the default is the right column, stacked above the minimap — the left one belongs to the mode rail and its panels. Other modes keep the bottom-left corner.
Default
'bottom-right' in full mode, 'bottom-left' otherwise
scope?
optionalscope:LegendScope
Defined in: interfaces/GraphUI.ts:599
Which collection this section keys on. 'edge' lists the graph's relation kinds with a line swatch — stroke colour, dash and marker as the renderer resolved them — and its toggles hide edge layers: the nodes stay put, and so do the layout, the selection and the camera.
An edge section filters whether or not UI.filter.edgeFacets declares its key: given one it drives that facet, so the panel and the legend are two views of one filter; without one it reserves a facet of its own.
Default
'node'Inherited from
showCounts?
optionalshowCounts:boolean
Defined in: interfaces/GraphUI.ts:628
Show a per-entry element count.
Default
trueInherited from
title?
optionaltitle:string
Defined in: interfaces/GraphUI.ts:610
Header text, used verbatim (so it can be translated).
Default
a prettified key, else 'Legend'