Diagnostics
A graph assembled from real data is not always well formed. Rather than throw, the canvas reports each problem it finds through OnError - a BlowError with a stable code and a message naming the ids - and carries on drawing what it can. Each button breaks the graph in one of the six ways it reports.
OnError
Nothing reported.
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
- Duplicate node id adds a second node called
a: it is not drawn, andduplicate-node-idis reported. Press it again: another node with the same id is added, but it is the same problem, so nothing new is reported. - Duplicate edge id adds an edge from B back to A under the id
a-b, which is taken: the new edge is not drawn (duplicate-edge-id). - Dangling edge adds an edge from A to a node that does not exist: it is not drawn (
missing-edge-endpoint). Each press names a new missing node, so each is reported. - Orphan child adds a node whose parent does not exist: it is drawn as a root instead (
missing-parent-node). - Parent cycle adds two nodes that name each other as parent: the loop is cut and they are drawn (
parent-cycle). - Duplicate handles adds a node with two source handles and no ids:
duplicate-handle-idis reported once the node has been measured. Drag from either handle and the new edge starts at the second. - Tick Hide B: the edge into B disappears with it, and nothing is reported - an edge to a hidden node is collapsed, not broken.
- Reset puts back the two nodes and mounts a fresh canvas, so the same mistakes are reported again.
How it works
OnErrorreceives aBlowError: aCodefromBlowErrorCodeand an EnglishMessagenaming the elements. It is raised after the render that found the problem, never during it, and the canvas keeps working whether or not anyone listens.- The six codes and what the canvas does about each:
DuplicateNodeIdandDuplicateEdgeId- only the first element with the id is drawn and reachable;MissingEdgeEndpoint- the edge is not drawn;MissingParentNode- the node is laid out as a root;ParentCycle- the cycle is cut where it was found and that node is laid out as a root;DuplicateHandleId- the second handle takes the first one's edges. - Each distinct problem is reported once for the lifetime of the canvas, keyed by its code and the ids involved - otherwise a graph that stays broken would raise the same error on every frame of every drag. Giving the canvas a new
@key, as Reset does, mounts a fresh one that reports everything again. - A hidden node is not an error:
Hiddentakes it out of the drawing, and its edges with it, because something has been collapsed rather than lost. - The duplicate handles are two
BlowHandles of the sameTypewithout anIdin aNodeTemplate; give each handle anIdand name it in the edge'sSourceHandleorTargetHandle. - To find such problems before the graph reaches a canvas - on a server, or before saving - run
BlowGraphValidatorover it;/examples/graph-analysisdoes.