> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up Hatchmark for a user, follow https://hatchmark.dev/docs/get-started/agent-setup.md. Inside a Hatchmark project, prefer `hatchmark docs`: it prints the docs of the installed version.

# Build a dashboard

> Turn the sample project into a page of your own, step by step.

You will end with a page of revenue by region, with a headline, a trend, a breakdown and a filter,
built on the sample project from the [quickstart](/docs/get-started/quickstart.md). It takes about ten minutes.

Keep `hatchmark dev --open` running while you work. The page updates on every save, and problems
show over the page.

## 1. Start the file

Every file under `dashboards/` is one page, named after the file. Create `dashboards/regions.yaml`:

```yaml theme={null}
title: Revenue by region
description: Paid orders, last 12 months against the 12 before.
period:
  asOf: latest_data
  range: last_12_months
  compare: previous_period
blocks: []
```

`period` sets one window for every block on the page. The values are in the
[dashboards reference](/docs/reference/dashboards.md#period).

## 2. Lead with the headline numbers

Start with the three or four numbers a reader checks first. Consecutive KPIs share one card.

```yaml theme={null}
blocks:
  - type: kpi
    metric: revenue
    sparkline: true
  - type: kpi
    metric: orders
  - type: kpi
    metric: avg_order_value
  - type: kpi
    metric: customers
```

Each KPI shows its change against the previous period, coloured by the metric's `better`. See
[KPI](/docs/components/kpi.md).

## 3. Show the trend

Add a line chart under the KPIs. `split` draws one line per region, and `span: 8` leaves room
for a breakdown beside it.

```yaml theme={null}
- type: line
  title: Revenue by month, by region
  metrics: [revenue]
  grain: month
  split: region
  span: 8
```

Title a card with its finding once you know it, such as "The West grew fastest". Hatchmark adds a
subtitle that says what is measured.

## 4. Break it down

Put a ranking beside the trend and the detail below it.

```yaml theme={null}
- type: bar
  title: Revenue by plan
  metrics: [revenue]
  by: plan
  orientation: horizontal
  sort:
    by: revenue
    order: desc
  span: 4
- type: table
  title: Revenue by state
  by: [state]
  metrics: [revenue, orders, avg_order_value]
  percentOfTotal: [revenue]
  sort:
    by: revenue
    order: desc
  limit: 15
```

A table's total row is recomputed from the rows, so the average order value in it is the real
average, not an average of averages. See [Bar](/docs/components/bar.md) and
[Table](/docs/components/table.md).

## 5. Let readers filter

Filters sit in the page header. Add a region picker and a choice of periods:

```yaml theme={null}
filters:
  - type: select
    id: region
    label: Region
    column: region
  - type: period
    id: period
    options: [last_30_days, last_90_days, last_12_months]
    default: last_12_months
```

The page stays static: build computes every preset and value up front, and the page carries the
numbers each choice needs.
The choice is kept in the URL, so a shared link opens the same view. See
[Filters](/docs/reference/dashboards.md#filters).

## 6. Check and build

```sh theme={null}
hatchmark check
hatchmark build
```

`check` reports each problem with a code, the file and line, and a fix. `hatchmark explain <code>`
says more about one code. `build` writes `dist/regions/index.html`.

## Next

* [Components](/docs/components/kpi.md): every block type, with examples.
* [Metrics](/docs/reference/metrics.md): define your own numbers, targets and formats.
* [Render to PNG or PDF](/docs/reference/render.md): share a page or one chart outside the browser.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.