Expand description
Drawing a laid-out graph of boxes: swimlane bands, edges (polylines with
an arrowhead, a linetype, a width and an optional label placed clear of
the boxes) and node boxes (a wrapped label, an optional value line,
status badge and sparkline, and an accent bar), as one GGPlot of
ordinary layers.
Works with graph_layout: size the boxes with
node_box, lay them out with layered,
then draw the result. What each mark says and what colour it takes
is the caller’s (the DrawNode / DrawEdge fields); where things go
inside a box and along an edge is decided here. Every mark carries the
caller’s data-* attributes, and what belongs to one node is wrapped in
<g data-of="<id>">, so a browser can address a node as one element.
Moved here from anofox-visualization’s ::DIAGRAM
(sipemu/ggplot-rs#497, DataZooDE/anofox-visualization#1153).
Structs§
- Draw
Edge - What an edge looks like, and its attributes. Its points come from the
layout (
GraphLayout::edges); the arrowhead is on its last point. - Draw
Node - What a node’s box shows, and its attributes. Its geometry comes from the
layout (
PlacedNode); its label lines fromnode_box. - Graph
Style - The colours and class names of a drawing.
- NodeBox
- A node box’s size and its label wrapped to fit.
Enums§
- Edge
Line - An edge’s line pattern.
Functions§
- draw
- Draw a laid-out graph on a
layout.w×layout.hpx canvas:lanesnames the layout’s bands,nodesandedgesare in the layout’s order.themeis the base (a void theme; the legend is turned off). Render the result with e.g.render_svg_native_at(0.0, 0.0, w, h)at the canvas size rounded up. - edge_
label_ width - The width (px) of an edge label as
drawsets it (its widest line): the layout’sGraphEdge::label_w. - flow_
width - An edge’s width (px) for what it carries,
valueof the graph’smax: area-true (sqrt), 1.4 px to 7 px; 1.6 px without a value; dotted edges 3–6 px so their dots show. Rounded to 0.1 px. - node_
box - The box a node needs: its label wrapped onto at most three lines, plus a
line for
value, a badge row forbadgeand a sparkline strip whenspark(asdrawfills it).
Type Aliases§
- Data
Attr - A
data-*attribute: its name (withoutdata-) and value;Noneleaves it off that mark.