Chart

✓ functional

Tell the Chart tab what story to draw before the result even arrives.

The chart directive prepares the result's Chart tab from a comment. It is the same chart you can configure interactively, but the setup travels with the query and comes back on every run. Use a view directive to open the Chart tab and a chart directive for the type, labels, series, and aggregation.

Syntax

-- sqlly view: chart
-- sqlly chart: kind:<type>[; label:<col>][; values:<cols>][; aggregate:<agg>][; order:<order>][; top:<n>][; navigate:<true|false>]

Fields are separated by ; and written as key:value; order does not matter. Only kind: is required, and the rest use the chart's defaults when omitted. Column names are flexible, so [Region], `Region`, and "Region" all resolve to the same column.

FieldMeaning
kind:The chart type: bar, line, area, scatter, histogram, pie, or donut (required).
label:colColumn whose values label the categories. Defaults to the first text column.
values:col[,col…]Numeric column(s) to plot as series. Defaults to auto-detecting the numeric columns.
aggregate:aggCollapse rows per category: none, sum, average, minimum, maximum, or count. (avg/min/max also accepted.)
order:orderCategory order: source, category (A–Z), or value (high–low).
top:nKeep at most n categories after ordering.
navigate:true|falseClicking a mark selects its source rows on the Grid tab (default true).

Examples

-- sqlly view: chart
-- sqlly chart: kind:bar; label:Region; values:Sales
SELECT Region, Sales FROM sales;

For two series, summed per category and shown largest first:

-- sqlly view: chart
-- sqlly chart: kind:line; label:Month; values:Revenue,Cost; aggregate:sum; order:value; top:12
SELECT Month, Revenue, Cost FROM monthly;

Chart types

Each kind: value draws a different mark. The gallery below names what to expect; its screenshot placeholders are waiting for their real captures.

SQLly
A SQLly bar chart
kind:bar - grouped bars around a zero baseline, one bar per series per category.
SQLly
A SQLly line chart
kind:line - one polyline per series, with gaps at NULLs.
SQLly
A SQLly area chart
kind:area - filled polylines on a zero-floored axis.
SQLly
A SQLly scatter chart
kind:scatter - per-category point markers, good for spread.
SQLly
A SQLly histogram
kind:histogram - nice-edged bins of a single numeric column.
SQLly
A SQLly pie chart
kind:pie - radial shares of a single non-negative series.
SQLly
A SQLly donut chart
kind:donut - a pie with the center hollowed out.
Use standalone comment lines. Put view: chart on the first non-empty line of the query; chart: can live on any comment line of its own. When several valid chart hints exist, the last one wins.