Skip to content
Visualization

Charts as SQL

CREATE CHART wraps a query and returns SVG. Ten chart types, one grammar. The chart definition lives in the same SQL file as the query that feeds it.

BAR, HBAR, LINE, AREA, SCATTER, PIE, HISTOGRAM, HEATMAP, RADAR, CANDLESTICK
SVG output, returned as a query result
Modifiers: TITLE, SUBTITLE, XLABEL, YLABEL, LEGEND, SMOOTH, BINS, VALUES, GROUP BY
BAR LINE PIE HEATMAP SCATTER RADAR HISTOGRAM AREA stacked CANDLESTICK

The shapes you reach for most

Comparisons, distributions, trends, and a few specialty charts

Comparisons

Bar and horizontal bar for category comparisons. Pie for share-of-whole.

Trends over time

Line and stacked area for ordered axes. Series come from a single SELECT, pivot with GROUP BY.

Distributions and density

Histogram for shape, heatmap for two-axis density, scatter for bivariate cloud.

Specialty

Radar for multi-KPI comparisons, candlestick for OHLC time series.

The whole chart is one statement

A SELECT inside, axes and titles outside

CREATE CHART BAR FROM (
  SELECT category, ROUND(SUM(revenue), 2) AS rev
  FROM retail.sales_daily
  GROUP BY category
  ORDER BY rev DESC
) X category Y rev
TITLE 'Revenue by Category'
VALUES ON;

Render where the data lives

Try the chart gallery demo in the GUI.