Skip to content

Edge Toolbar

Selecting an edge opens a BlowEdgeToolbar at its midpoint, drawn through EdgeLabelTemplate so it keeps the same size at any zoom: a text box renames the edge, one button recolours it and another deletes it.

step 1 step 2
Start
Middle
End
bit Blow

Try it

  • Click an edge: a toolbar opens just above its label, and closes again when you click the empty pane.
  • Type in the toolbar's box: the edge's label changes as you type. Backspace in the box edits the text; it does not delete the edge.
  • ๐ŸŽจ gives the edge the next colour in a short palette; the line and its arrowhead change, and the selection shows as a thicker line rather than the selection colour, so the new colour stays visible.
  • ร— deletes the edge.
  • Scroll to zoom with an edge selected: the edge grows and shrinks, the toolbar keeps its size.
  • Drag from a node's bottom dot to another node's top dot to add an edge, then select it: it has the same toolbar. Reset edges puts the starting edges back.

How it works

  • EdgeLabelTemplate renders HTML at each edge's label point in an overlay that is not zoomed; this one renders nothing unless ctx.Edge.Selected.
  • BlowEdgeToolbar is a styled container (Class, Style) that keeps its presses, clicks and right-clicks from reaching the pane, so its buttons and text box work without the nopan class and pressing them leaves the edge selected.
  • While focus is in a text box the canvas ignores its graph keys, so typing never deletes or moves anything.
  • The EdgeTemplate draws each edge with BlowBaseEdge in the colour kept in the edge's Data, passes ctx.MarkerEndUrl on for the arrowhead, and sets a --edge-colour custom property that a page style uses for the selected edge.
  • The buttons change the BlowEdge in place - Label, Data - or remove it from the Edges list; the canvas draws the change on the next render.
An unhandled error has occurred. Reload 🗙