Custom Edges
An EdgeTemplate draws every edge itself, here with BlowBaseEdge: each edge's colour comes from its Data, a selected edge thickens, and the label is drawn with BlowEdgeText on a plate tinted to match. Whatever the template leaves out - the arrowheads, say - the edge does not have.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Each edge is drawn in the colour its data names, with its label on a plate tinted to match.
- Click an edge: it thickens to 4 pixels and takes the selection colour.
- Untick Arrowheads: the template stops passing the arrowhead on, and every edge loses it, although each edge still asks for one.
- Untick Tinted labels: the labels fall back to the plain plate
BlowBaseEdgedraws. - Drag from a node's bottom dot to another node's top dot: the new edge is a smooth step, drawn by the same template in the theme's edge colour, since it carries no data.
How it works
EdgeTemplatereplaces how every edge is drawn. It receives aBlowEdgeContext: theEdge, its computedPath,LabelXandLabelY, its two anchors and sides, andMarkerStartUrl/MarkerEndUrl.BlowBaseEdgedraws the standard edge from aPath: the visible line with itsStrokeandStrokeWidth(1.5 by default), the arrowheads given asMarkerStartandMarkerEnd, an optional plainLabelatLabelX,LabelY, and an invisibleInteractionWidth-wide path (14) that takes the clicks.- The colour is the edge's
Data- any object of yours, here a CSS colour string - withvar(--bit-blow-edge-stroke)for an edge without one.Edge.Selectedpicks the width; the canvas's selection colour still overrides the stroke. MarkerEndUrlis a ready-madeurl(#...)to the arrowhead the edge'sMarkerEnd,MarkerTypeand colour settings ask for, so the template never needs the generated marker ids. Passing null leaves the edge without one.BlowEdgeTextdraws a label on its own plate at any point:X,Y,Label,Stylefor the text,BgStylefor the plate,PaddingX,PaddingY,BorderRadiusandShowBg.DefaultEdgeTypeandConnectionLineTypemake new edges, and the line drawn while connecting, smooth steps like the edges already there. Around the template's markup the canvas still draws the selectable, focusable edge group.