Skip to content

Charts

Charts draws 79 chart types from six engines. This page shows how to choose one, how to ask for advice, and how to draw anything that is not one of the 14 typed recipes.

Choose by question

Family Types For
Comparison 12 Comparing a value across categories: bars, lollipops, dumbbells, bullets, waterfalls.
Trend 18 A value over time: lines, areas, streamgraphs, slopes, bumps, dual axes, small multiples.
Distribution 10 The shape of data: histograms, densities, box plots, strips, heatmaps, 2-D histograms.
Part to whole 7 Shares of one whole: pies, donuts, stacked and 100% stacked bars, radial bars, funnels, gauges, waffles.
Relationship 10 Two or more measures together: scatters, bubbles, regressions, correlation matrices, parallel coordinates, radar.
Flow 3 Movement and connection: Sankey, chord and network diagrams.
Hierarchy 3 Nested structure: treemaps, sunbursts and trees.
Map 6 Geography: choropleths, symbol maps, hex and tile cartograms, flows on a map.
Text 1 Word clouds.
Table 2 Publication data-graphic tables and KPI cards.
Diagram 7 Mermaid and structured diagrams.

Ask the catalogue

tools.charts.catalogue is the agent's own list. With no input it answers every type, its family, its engine and a working example. With an id it answers that type's tested call:

{ "id": "bar" }

tools.charts.recommend ranks chart types for a question and the data, and never renders:

{ "request": "How did revenue change by region over the year?", "data": { "path": "data/revenue.csv" }, "limit": 3 }

Draw a raw spec

Outside the 14 recipes, tools.charts.render takes a Vega-Lite spec, a Vega spec or an ECharts option, with the data either inline or in a workspace file:

{
  "spec": {
    "$schema": "https://vega-lite.github.io/schema/vega-lite/v6.json",
    "mark": { "type": "bar" },
    "encoding": {
      "x": { "field": "product", "type": "nominal", "sort": "-y" },
      "y": { "field": "revenue_eur", "type": "quantitative" }
    }
  },
  "data": {
    "rows": [
      { "product": "Atlas", "revenue_eur": 820 },
      { "product": "Borealis", "revenue_eur": 540 },
      { "product": "Cinder", "revenue_eur": 310 }
    ]
  },
  "title": "Revenue by product"
}

tools.charts.validate takes the same input and writes nothing. tools.charts.plan_render previews the files and changes, and tools.charts.render commits them.

What the engines cover

Engine What it draws
Vega-Lite Statistical charts, maps, layers, facets and most of the catalogue.
Vega Treemaps, sunbursts, trees, force networks and word clouds.
ECharts Sankey, chord, gauge, funnel, calendar, candlestick, radar and parallel coordinates.
Observable Plot The Plot recipes, for a compact marks-and-data form.
Table Publication data-graphic tables.
Diagram Mermaid and structured diagrams.

Checks before a file

Every call validates first and explains each problem with its JSON path and a fix. The linter also reports a chart that would mislead or read badly:

  • an axis that does not start at zero where it matters (TRUNCATED_AXIS);
  • a pie with too many slices or a negative value (PIE_TOO_MANY_SLICES, PIE_NEGATIVE);
  • overlapping labels, clipped labels or too many series (LABEL_COLLISION, LABEL_CLIPPED, TOO_MANY_SERIES);
  • a rainbow sequential scale, low contrast or missing units (RAINBOW_SEQUENTIAL, LOW_CONTRAST, MISSING_UNITS);
  • an aggregation that a mark needs and the call does not state (AGGREGATION_REQUIRED).

A warning does not stop the call. An error does, and nothing is written.

Formats

A raw call writes SVG, PNG and the resolved spec by default. Add html for an interactive, offline page, gif for an animation, and document for the editable <name>.chart.json. A recipe call writes SVG, PNG, the spec and the document, plus the HTML page when an interaction needs it. svgText chooses text, paths or embedded fonts in the SVG.