draw
Builds a dashboard on the user's screen from read-only SQL, datasets, charts, tables, and notes in one call.
Instructions
Draw a board on the user's screen in one call. items, in reading order:
a part: sql (one read-only SELECT), dataset or source, with an optional title. The chart is picked from its rows: dates with numbers → line, labels with numbers → bars, one row → headline numbers, else a table; rows like (date, name, value) get a line per name. Choose yourself with show, x, y, series and formats, or draw it with any component and props (its dataset is filled in).
{note, title?, tone?}: your text. Quote only figures you have read.
{row: [parts]} side by side; {section, subtitle?, items} a titled group. The database computes every number: aggregate, rebase and round in SQL. Put values the user may change in params (:name in the SQL) and add save_as to keep the board as a recipe, so the same board for other values is one recipe call. Returns the rows of each part (the first and last of long ones) to check. Components: Grid {columns?}: Places its children side by side in equal columns, wrapping to new rows. Section {title, subtitle?}: A titled group of children, stacked. Metric {label, dataset, field, row?, format?, caption?}: One headline number read from a dataset cell (row 0 unless row is set). LineChart {dataset, x, y, title?, format?}: Lines over x (dates or ordered labels), one line per y column. BarChart {dataset, x, y, title?, format?, horizontal?}: Bars per x category, one bar per y column. horizontal suits long labels. PieChart {dataset, label, value, title?, format?}: Donut of value by label; beyond 7 slices the rest are grouped as Other. Table {dataset, columns?, limit?, title?}: Rows of a dataset. columns picks and orders them (all when omitted): column names, or { field, label?, format? }. Note {text, title?, tone?}: Your explanation in plain text. Lines starting with '- ' become bullets; bold works. tone colours it. ActionButton {label, action, input?}: A button that runs one of the app's actions (see get_screen) with the given input. The app can add its own components; get_screen lists them.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Replace this board instead of adding one | |
| items | Yes | ||
| title | Yes | May use {param} to show a value | |
| params | No | Values for :name placeholders in the SQL; lists as arrays | |
| save_as | No | Keep as a recipe; params become its inputs | |
| preview_rows | No | Rows of each part returned to you (default: all of a small result, else the first 3 and the last) |