Diagrams¶
tools.charts.diagram draws a diagram offline: Mermaid source, or a structured recipe that the engine lays out itself. It returns a self-contained SVG, a PNG and a Unicode outline for a terminal. Every write is a plan and a commit: tools.charts.plan_diagram previews, and tools.charts.diagram writes.
Give either dsl or kind, never both.
Mermaid source¶
dsl takes Mermaid source for a flowchart, sequence, state, class or ER diagram:
{
"dsl": "flowchart LR\n intake[Intake] --> triage{Triage}\n triage -->|bug| fix[Fix]\n triage -->|feature| build[Build]\n fix --> ship[Ship]\n build --> ship",
"title": "From intake to ship"
}
The engine draws it with the bundled fonts and the active theme, so no label clips and nothing is fetched. Supported first lines are graph, flowchart, sequenceDiagram, stateDiagram-v2, classDiagram and erDiagram.
Structured recipes¶
kind takes one of four recipes:
| Kind | Takes |
|---|---|
mindmap | nodes with a parent, and optionally root for the centre and layout (horizontal or radial). |
org_chart | nodes with a parent; direction sets the flow. |
fishbone | effect (the question the diagram explains) and categories, each with its causes. |
architecture | nodes, edges and groups, each group drawn as a subgraph. |
A mindmap:
{
"kind": "mindmap",
"root": { "label": "Charts" },
"nodes": [
{ "id": "engines", "label": "Six engines" },
{ "id": "vega-lite", "label": "Vega-Lite", "parent": "engines" },
{ "id": "vega", "label": "Vega", "parent": "engines" },
{ "id": "echarts", "label": "ECharts", "parent": "engines" },
{ "id": "outputs", "label": "Outputs" },
{ "id": "svg", "label": "SVG", "parent": "outputs" },
{ "id": "png", "label": "PNG", "parent": "outputs" }
],
"layout": "radial"
}
direction (TD, TB, LR, BT or RL) sets the flow of a graph, flowchart or architecture diagram. A node takes id, label, an optional subtitle, parent, group and colour. An edge takes from, to, an optional label and a style of solid, dotted or thick.
The outline¶
Every diagram also answers a Unicode ascii outline in the result, for a terminal or a chat message that cannot show the picture. The outline is drawn from the same layout, so it names the same nodes and edges.
Output¶
The call writes the SVG and PNG under outputs/charts/ (or the configured outDir), with the frame's own title, subtitle, kicker, source and notes drawn inside the picture.