Dashboards in Markdown

A dashboard in Dash is a page: one Markdown file with text, and sql blocks that show their result as a chart, a table, a number or a dropdown. You edit it like a document, block by block, or as the Markdown itself next to it. The file reads fine without Dash, works in git, and is easy for a coding agent to write.

Blocks

A sql fence with a view line is a block that shows data:

```sql busiest_stations
-- view: bar
-- x: StationName
-- y: num_services
SELECT StationName, count(*) AS num_services
FROM 'https://example.org/services.parquet'
GROUP BY ALL ORDER BY num_services DESC LIMIT 10
```

The word after sql names the block (busiest_stations) and is its title, "Busiest stations". The -- key: value lines on top say how to show it:

KeyMeaning
viewbar, line, area, scatter, pie, radar, table, text, select (a dropdown) or slider
xA chart's x axis column; for pie the slice label
yA chart's value columns, comma separated
columnThe column a select offers
rowsHeight in rows of 48 px, 6 when left out
inputA query file to show instead of SQL of its own: -- input: ../orders.sql

Connecting blocks

A block reads another block of its page with refs.<name>(). A dropdown passes on only what is picked, or everything while nothing is, so a dropdown filters every block reading it:

```sql service_type
-- view: select
-- column: ServiceType
SELECT DISTINCT ServiceType FROM 'https://example.org/services.parquet'
```

```sql busiest_stations_of_type
-- view: bar
-- x: StationName
-- y: num_services
SELECT StationName, count(*) AS num_services
FROM 'https://example.org/services.parquet'
WHERE ServiceType IN (SELECT ServiceType FROM refs.service_type())
GROUP BY ALL ORDER BY num_services DESC LIMIT 10
```

Pick a service type and the chart runs again for it. A query saved as a .sql file of the project is read the same way, refs.<file name>(), from every page; from outside Dash it is the DuckDB macro dash.refs.<file name>().

Side by side

Blocks stack top to bottom. Put them next to each other in a row of columns, spans out of 12:

<columngroup>
<column span="7">

```sql busiest_stations
...
```

</column>
<column span="5">

Utrecht Centraal is the busiest station, ahead of Amsterdam Sloterdijk.

</column>
</columngroup>

Link another page by its path relative to this one, [Disruptions](Disruptions.md). Renaming or moving a page rewrites the links to it.