Observable Plot Charts

Create a chart with a fenced plot block. Its contents are JSON, not JavaScript. Each mark has a type and optional options:

```plot, [.description: "Beta has seven orders, compared with four for Alpha."]
{
  "width": 480,
  "height": 280,
  "title": "Orders by team",
  "subtitle": "This quarter",
  "caption": "Source: team records",
  "color": {"legend": true},
  "data": [
    {"team": "Alpha", "orders": 4},
    {"team": "Beta", "orders": 7}
  ],
  "marks": [
    {"type": "barY", "options": {"x": "team", "y": "orders", "fill": "team"}},
    {"type": "ruleY", "data": [0]}
  ]
}
```

Common marks include barX, barY, line, lineY, dot, areaY, rectY, ruleY, and text. Use Observable Plot’s mark and scale options as a reference, within the static-chart limits below.

Titles, legends, and styling

title, subtitle, and caption add plain text around the chart. width and height describe the chart area; the complete figure grows vertically to include its surrounding content. Headings, captions, and flow-legend labels wrap to fit. Legends arranged with columns use single-line labels with an ellipsis when necessary.

Set legend: true on the color, symbol, or opacity scale to show its legend. Color legends support categories and continuous gradients. Use color.scheme or color.range for an explicit palette. Deckset otherwise supplies theme colors and fonts. Authored fills, strokes, transparency, dashed lines, clipping, rotated labels, and text outlines are retained where supported by native rendering and exports.

Read a local CSV or JSON file

Replace inline data with dataFile:

{
  "dataFile": "sales.csv",
  "dataTypes": {"id": "string", "date": "date", "revenue": "number"},
  "marks": [{"type": "lineY", "options": {"x": "date", "y": "revenue"}}]
}

Keep sales.csv beside the Markdown file, for example:

id,date,revenue
0001,2026-01-01,20
0002,2026-01-02,35
0003,2026-01-05,52

Paths are relative to the presentation. A TextBundle can read from its assets directory. CSV needs a header row. JSON files must contain an array of objects or an object with a data array. If both dataFile and inline data are present, the file takes precedence. Remote URLs and JavaScript fetch are not supported.

Without dataTypes, CSV values are inferred as numbers, booleans, strings, or null for empty cells. Declare types for individual columns when the distinction matters:

Type Behavior
string Preserves leading zeros and empty CSV cells.
number Accepts finite decimal or scientific values.
boolean Accepts true/false values, including case-insensitive strings.
date Accepts YYYY-MM-DD at midnight UTC, or ISO timestamps with an explicit timezone.

Empty non-string cells and JSON null remain null. Invalid typed values report the column and data row. A mark with its own data can also declare its own dataTypes.

Group and bin values

Use one transform per mark: groupX, groupY, binX, or binY. Supported reducers are count, sum, and mean. Put input channels and bin settings in the mark’s options.

This mark sums revenue for each region:

{
  "type": "barY",
  "transform": {"type": "groupX", "outputs": {"y": "sum"}},
  "options": {"x": "region", "y": "revenue"}
}

Place it inside marks and supply data with region and revenue columns. To count values in a histogram, use this mark with a numeric units column:

{
  "type": "rectY",
  "transform": {"type": "binX", "outputs": {"y": "count"}},
  "options": {"x": "units", "thresholds": [0, 20, 40, 60], "domain": [0, 60]}
}

groupY and binY are the horizontal counterparts; use an x output with barX or rectX. sum and mean need an input channel; count does not. Transform chaining, custom reducers, and JavaScript expressions are not supported.

Refresh and share linked data

While the presentation is open, Deckset refreshes affected charts when a linked file is edited or replaced. Removing a file shows an error figure; restoring it allows the chart to recover without reopening the presentation.

Converting a Markdown presentation to a TextBundle copies available Plot datasets into assets/plot-data and updates their references. Move or share the whole bundle. Missing datasets cannot be copied: their references remain unchanged and those charts need the missing files restored.

Footer and pause-screen limitation: external datasets in quoted YAML footer or pause-screen values are not reliably retained by TextBundle conversion. Use regular slide content, Deckset multiline blocks, YAML literal blocks (|), or inline chart data instead. See the packaging guidance.

Accessible descriptions

Add [.description: "..."] or [.desc: "..."] to the opening fence, as in the first example. Explain the main trend, units, and context. Deckset carries this text into accessible PDF figures and HTML image alternative text. Titles and captions do not automatically become the accessible description; without one, the chart uses the generic label “Observable Plot Graph”.

For exact values, include a Markdown table alongside the chart or on a following slide. The description does not generate an accessible data table.

Limits and errors

Deckset renders static vector figures locally. Interactive marks/tooltips, canvas-backed raster marks, embedded image marks, pattern-based waffle marks, arbitrary JavaScript, and HTML-rich captions are unsupported. Upstream options requiring browser layout or unsupported native SVG features may also produce an error.

Malformed JSON, missing files or columns, invalid typed values, and unsupported rendering options appear as diagnostic figures. Check the figure and export warnings, correct the specification or source data, and let Deckset reload the chart.

Find a topic, command, or Markdown example.