本文へ移動

@eightkk/vue-weave / core / placeGraphEdgeLabels

Function: placeGraphEdgeLabels() ​

placeGraphEdgeLabels<L, E>(layout, edges, options?): L

Defined in: src/core/graphLabelPlacement.ts:206

Places edge labels where they do not cover node boxes, other labels or other edges, when there is space for them, and returns a new layout with the new edgeLabels; the input is not changed. Each label is tried at positions along its route, beside it on either side and on it, and the one with the least overlap wins, preferring positions near the middle of the route and above or right of it. Labels are placed one at a time, those of shorter routes and then wider labels first, ties in edge ID order, so the result is deterministic.

Anchors keep the meaning of GraphLayout.edgeLabels: the horizontal centre and the baseline of the text, as NetworkGraph and renderGraphSvg draw it. Label sizes are estimated from the text length unless labelSize gives them. Throws an Error for an invalid or duplicate edge ID (Duplicate edge ID: <id>), an edge without a layout path or an unknown ID in edgeIds, and a RangeError for an invalid option, label size, edge width or obstacle (naming its index).

Type Parameters ​

L ​

L extends GraphLayout

E ​

E extends GraphEdge<unknown> = GraphEdge<unknown>

Parameters ​

layout ​

L

edges ​

readonly E[]

options? ​

GraphEdgeLabelPlacementOptions<E> = {}

Returns ​

L

MIT ライセンスで公開しています。