svg_line_chart
aggregate · LOAD svg_charts
svg_line_chart(ANY, DOUBLE) -> VARCHARCollapses a group of rows into one line chart.
SELECT svg_line_chart(month, sales) FROM monthly_sales;An aggregate, so it collapses a group the way sum() collapses it into one number — and so GROUP BY gives you one chart per group:
SELECT regionid, svg_line_chart(ts, avg_rrp) AS chart
FROM prices_monthly GROUP BY regionid;x may be a date, timestamp, boolean, number or string; it becomes the axis label, formatted for you. y is a DOUBLE. The optional third argument is the options struct described in charts.
Order the input yourself
Points are plotted in the order they arrive, and a plain aggregate over a parallel scan receives them in arbitrary order — an unsorted line chart comes out scrambled.
svg_line_chart(ts, y ORDER BY ts) looks like the obvious fix and does not work: it renders a single point. DuckDB’s sorted-aggregate path feeds the C API a state vector this extension cannot read correctly, and cannot detect the case either. Use svg_chart with list(… ORDER BY …), or sort in a subquery before the aggregate sees the rows.
Requires LOAD svg_charts — a separate extension from duckweb, and one an app that draws at render time needs resident in the server, not only in the build that produced its database.