Charts
Author charts in the ChartBuilder, wire them into dashboards, export to PNG/PPTX/XLSX, and inspect the compiled SQL behind every tile.
Author charts against metrics, saved queries, or raw SQL. Every save is a git commit; every tile exposes its compiled SQL.
You’ll learn
- How the
/charts/newand/charts/:id/editChartBuilder is laid out- The chart CRUD endpoints: list, get, put, delete, history, at-SHA, compiled-sql
- What the dashboard tile menu can do (drill, view query, view as table, share, download)
- How PNG / PPTX / XLSX export works and how RBAC gates every chart
The ChartBuilder page
The ChartBuilder lives at /charts/new and /charts/:id/edit. It renders a three-pane layout: a Source picker on the left, a live Preview with a chart-kind grid in the middle, and an Encodings + Filters + Limit inspector on the right. Every save is a real git commit through PUT /api/charts/{id}, so the same history and diff plumbing you get for dashboards lights up for charts for free.
Source kinds
A chart’s source_kind is one of three values:
metric- point at a semantic metric, pickdimensions,time_grain,filters,time_range, andlimit. Compiled through the semantic layer so the SQL you see is byte-identical to the one running in production.sql- paste raw ClickHouse SQL. May embedqr.<query_id>references that expand to the referenced saved query at run time.query_ref- reference a saved query by id. The referenced query is re-gated by the caller’s workspace and per-query ACL.
The SQL IDE’s ”+ Visualization” button seeds /charts/new?sql=... or ?query_ref=... so you jump straight from a run result into ChartBuilder with the source pre-populated.
Chart kinds
The chart-type grid renders every entry in ALL_CHART_KINDS:
line, area, bar, stacked-bar, horizontal-bar, donut, pie, scatter,
heatmap, gauge, funnel, treemap, sankey, candlestick, parallel,
geo-country, big-number, table, pivot, gantt, cohort, bubble,
box-plot, histogram, waterfall
Each kind declares which encoding slots it consumes. The Encodings inspector only shows slots the current kind consumes - swap kinds and the panel morphs.
Undo, dirty, autosave
ChartBuilder maintains bounded past/future stacks (cap 50) and binds Ctrl/Cmd-Z + Ctrl/Cmd-Shift-Z (or Ctrl/Cmd-Y) to undo/redo, skipping when the focus is inside an <input>, <textarea>, or contenteditable. An isDirty chip appears in the header when the current chart JSON differs from the last save; the beforeunload guard blocks a stray tab close.
Save and Save-as
Two commit paths:
- Save (
Cmd/Ctrl+S) - write the current id. The response echoes anETag; the nextPUTsendsIf-Matchand a stale value returns412 Precondition Failedso two editors can’t silently clobber each other. - Save as… (
Cmd/Ctrl+Shift+S) - fork. Collect a new name in the in-tree focus-trapped dialog, mint a fresh id, and always navigate into the new chart’s editor. Save-as is never a no-op fork - a rename plus save keeps the same id, save-as always creates a new one.
When a chart is opened from inside a dashboard tile, the same Save as new tile path lets you fork the tile out into a standalone /charts/:id so subsequent edits don’t drag every dashboard that embeds the source.
Chart CRUD
All routes require an authenticated caller.
| Method | Path | Permission | Notes |
|---|---|---|---|
| GET | /api/charts | allow_charts filter | Returns charts the caller can see. Empty allow_charts denies. ?workspace=<id> scopes the sidebar switcher. |
| GET | /api/charts/{id} | workspace + allow_charts | 404 (not 403) when restricted, so existence is not leaked. |
| PUT | /api/charts/{id} | allow_save + workspace + allow_charts | If-Match optimistic concurrency; author is forced to the authenticated user. |
| DELETE | /api/charts/{id} | allow_delete + workspace + allow_charts | 400 on invalid id, 404 on missing, 500 on git partial failure. |
| GET | /api/charts/{id}/history | workspace + allow_charts | Commit log for the chart YAML. |
| GET | /api/charts/{id}/at/{sha} | workspace + allow_charts | Retrieve the chart as it was at any commit SHA. |
| GET | /api/charts/{id}/compiled-sql | workspace + allow_charts (+ allow_metrics for metric sources) | Returns {chart_id, sql, dialect: "clickhouse"}. |
The history and at/{sha} handlers walk deleted charts too, gating on the workspace stored in the last committed YAML so a delete + fetch is not a leak path.
The tile menu
Chart tiles on dashboards carry a ... menu mirroring Superset’s ordering:
- Force refresh - bust the cache and re-fetch.
- Enter fullscreen - expand the tile.
- Edit chart - open the chart in ChartBuilder. Disabled when
canEditis false. - View query - open the ChartQueryModal. This fires
GET /api/charts/{id}/compiled-sqland prints the ClickHouse SQL the tile is running. Disabled for inline metric tiles that have no chart id. - View as table - switch the tile to the ChartTableModal which renders the underlying rows.
- Drill to detail - expand a mark into row-level detail (respects the tile’s dimensions and time range).
- Share - open the ChartShareModal. Copies a permalink and, where wired, generates an embed token for anonymous embeds.
- Download PNG / CSV / XLSX - see below.
The Open in IDE affordance is offered on sql and query_ref source kinds: it pipes the compiled SQL from /api/charts/{id}/compiled-sql into the SQL IDE for further editing. See SQL IDE.
Exports
Two server-generated formats live under /api/export:
PNG
Client-side. The chart is rendered to a data:image/png;base64,... blob in the browser with no server round-trip.
XLSX
POST /api/export/xlsx.
{
"filename": "revenue-2026.xlsx",
"sheets": [
{ "name": "MRR", "columns": [{"name":"month","type":"Date"},{"name":"mrr","type":"Float64"}], "rows": [["2026-01","41200.00"]] }
]
}
Numeric-typed columns are coerced so Excel right-aligns them and SUM() works; date and timestamp columns land as real cells. Caps: 16 MiB request body, 1M cells per sheet, 500 columns per sheet, 31-char sheet names.
PPTX
POST /api/export/pptx. Hand-crafted OOXML written into a zip with no sidecar dependency.
{
"filename": "board-deck.pptx",
"title": "Q3 review",
"slides": [
{
"title": "MRR",
"subtitle": "Trailing 12 months",
"png_data_url": "data:image/png;base64,iVBORw0KGgo...",
"columns": [{"name":"month","type":"Date"},{"name":"mrr","type":"Float64"}],
"rows": [["2026-01","41200.00"]]
}
]
}
One 16:9 slide per entry, with a title, an optional embedded PNG (the chart snapshot from the client), and an optional data table underneath. Caps: 32 MiB body, 100 slides, 8 MiB per embedded PNG, 200,000 cells per slide. Both .pptx and .xlsx writes append an audit-log entry (export.pptx, export.xlsx) so a compliance auditor can reconstruct who exported what.
Note: PNG data URLs are validated by magic bytes and rejected if they are not real PNGs.
RBAC: allow_charts is default-deny
An empty allow_charts list is a deny-all, not an allow-all. A trial signup or new role must plant at least ["*"] in policies.yml or the user sees an empty catalog. Anonymous callers are always denied. Layered on top of that:
- Workspace membership is checked first; non-members receive 404, not 403, so restricted workspaces are not enumerable.
- Per-chart id ACL runs on top of the workspace gate on every route including delete and history, so a user with
allow_deletebut noallow_chartsentry for a specific id cannot delete it. compiled-sqladditionally re-gates any referenced saved query (qr.<id>in sql-body charts, or thequery_idforquery_ref) via the same 404-on-deny rule.
For the full role and workspace model see Access control - Workspaces and membership.
Related
- Metrics - the source of truth for
source_kind: metriccharts - Notebooks - embed a metric or SQL cell in a narrative alongside chart tiles
- Ask: grounded AI Q&A - ask a question, get a chart back
- Audit and lineage - every
chart.view_sqlandexport.*action is logged - Embedded analytics - surface a chart in a customer-facing UI
- REST API - the full endpoint table
Last updated