Charts and diagrams

Write the numbers as text, and siv draws the chart when it builds the site. Charts are images inside the page: they need no JavaScript, they print, and they follow the visitor's dark mode.

A bar chart # ↑

Write the data in a block named bar. Separate the columns with one tab: the first row names the series, the first column labels the points.

```bar title="Boats in the harbor"
Year	Sail	Motor
2023	15	28
2024	21	25
2025	26	24
```
Boats in the harbor Sail Motor 0 10 20 30 2023 2024 2025 2023, Sail: 15 2024, Sail: 21 2025, Sail: 26 2023, Motor: 28 2024, Motor: 25 2025, Motor: 24
Data
YearSailMotor
20231528
20242125
20252624
Boats in the harbor

A table copied from a spreadsheet is already tab-separated: paste it as it is. Under each chart, "Data" opens the numbers as a table, for screen readers and for anyone who wants the exact values.

A line chart # ↑

line draws one line for each series. An empty cell is a missing value, a gap in the line:

```line title="Water temperature" unit=" °C"
Month	2024	2025
May	8,5	9,1
Jun	14,2	15,0
Jul	19,8	
Aug	18,1	20,3
```
Water temperature 2024 2025 7,5 °C 10,0 °C 12,5 °C 15,0 °C 17,5 °C 20,0 °C 22,5 °C May Jun Jul Aug May, 2024: 8,5 °C Jun, 2024: 14,2 °C Jul, 2024: 19,8 °C Aug, 2024: 18,1 °C May, 2025: 9,1 °C Jun, 2025: 15,0 °C Aug, 2025: 20,3 °C
Data
Month20242025
May8,59,1
Jun14,215,0
Jul19,8
Aug18,120,3
Water temperature

Numbers can have a decimal comma, 8,5, and spaces between thousands, 12 000.

A stacked bar chart # ↑

stack puts the series on top of each other, to show the total:

```stack title="Visitors by season"
Season	Day trips	Overnight
Spring	120	40
Summer	480	210
Autumn	160	50
```
Visitors by season Day trips Overnight 0 200 400 600 800 Spring Summer Autumn Spring, Day trips: 120 Summer, Day trips: 480 Autumn, Day trips: 160 Spring, Overnight: 40 Summer, Overnight: 210 Autumn, Overnight: 50
Data
SeasonDay tripsOvernight
Spring12040
Summer480210
Autumn16050
Visitors by season

Options # ↑

After the name of the chart:

title="Text"    the caption, also read by screen readers
unit=%          added to the numbers on the axis: 50%
unit=" °C"      quotes keep the space: 20 °C

The series get the colors of a palette that works for color-blind visitors and on dark backgrounds. To change a color, add to templates/layout.css:

.chart .s1 { fill: #c00; stroke: #c00; }

A mistake in the data, like a word where a number should be, stops the build. The error tells the line to fix.

Sequence diagrams # ↑

A sequence block shows messages going back and forth, top to bottom:

```sequence title="Loading a page"
Browser -> Server: GET /charts/
Server -> Server: find the file
Server --> Browser: 200 OK
```
Loading a page Browser Server GET /charts/ find the file 200 OK
Steps
  1. Browser → Server: GET /charts/
  2. Server → Server: find the file
  3. Server → Browser: 200 OK
Loading a page

-> is a message and --> a reply, drawn dashed. The participants are drawn in the order they first appear. Lines starting with # are comments. "Steps" opens the messages as a numbered list.

A table instead # ↑

A tsv block becomes a table instead of a chart: Tables.

Next: Pages, folders and addresses