# Putting data in

https://docs.kleaver.ie/data-viz/data/

There are two ways to fill a chart, and both produce the same markup.

### 1 · In client.json, drawn at build time

Describe the chart under charts, then put its token in the page. The build draws the finished chart, and fails with a message naming the chart if the data is wrong (a funnel that grows, a pie with seven parts, a date that isn't a date).

```
"charts": {
  "visits": {
    "type": "bar",
    "title": "Visits by day",
    "data": [ { "label": "Mon", "value": 420 }, { "label": "Tue", "value": 510 } ]
  }
}

<!-- in the page -->
{{chart.visits}}
```

### 2 · Typed straight into the HTML

The markup is plain HTML, so a chart can be written by hand. This strip is two days:

```
<div class="strip" role="img" aria-label="Uptime, 2 days">
  <i class="strip__cell" data-state="up" title="1 Nov: Up"></i>
  <i class="strip__cell" data-state="down" title="2 Nov: Down"></i>
</div>
```

### Choosing the colours

Colours are a theme choice for the whole site, set on <html> like light and dark: data-chart-palette="dark2" for ColorBrewer Dark2 series colours (ggplot2 is the default), and data-chart-ordinal="viridis" for viridis on ordered charts such as the funnel and waffle (the brand colour is the default). The switcher at the top of this page sets the same attributes.

```
<html lang="en" data-theme="light" data-chart-palette="dark2" data-chart-ordinal="viridis">
```

Every chart type is documented in COMPONENTS.md, with its data shape. Colours come from the chart tokens in THEMING.md. Whatever the route, every number is also in the chart's "View as table" section, so nothing depends on colour or hover. The numbers on this page are **sample data**.
