# Dashboards

A dashboard is a grid of charts, each one backed by a DSL query against your tables, with optional filters, tabs and click-through drilldowns. This page covers how to define one, how the layout works, every chart type and its options, and a checklist for testing before you publish.

If you are new to the query language, read the [DSL overview](/docs/dsl/overview) first. Every chart on a dashboard is a DSL query that usually ends in a `.chart(...)` call. Table names in the examples (`gh.pr_enriched`, `enrich.developers` and so on) are illustrative: use the tables in your own catalog.

## Two ways to build a dashboard

### In the portal

Open **Dashboards** in the sidebar and click **New**. Give the dashboard a name and description and you land in the editor, where you can:

- **Add Widget** (or **Edit** on an existing widget): opens the chart editor. Give the chart a title and an optional **Description**, then either type a request into **Ask Scout to create or modify this chart...** and let [Scout](/docs/dashboards/scout) write the query, or write it yourself on the **DSL Query** tab. The **Drill Down DSL** tab holds the chart's [drilldown](/docs/dashboards/drilldowns). A live preview below shows the result as you go.
- **Add Panes** in the chart editor turns the chart into a [multi-pane widget](#multi-pane-widgets). Each pane gets its own title, description, query and drilldown, and **Set default** picks the pane that shows first.
- **Visual Builder** in the chart editor opens a point-and-click builder instead: pick a **Namespace** and **Table**, a **Chart Type** (Table, Line, Bar, Area, Pie, Scatter or KPI), axes and a **Time Filter**.
- **Filters**: add, edit and delete dashboard filters.
- Create tabs, move widgets between tabs, duplicate or delete widgets, then **Save**.

**Import** next to **New** creates a dashboard from a dashboard spec in a `.json`, `.yaml` or `.yml` file.

The chart editor accepts any query on this page, including sankey, gauge, multi-pane widgets and `navigate(...)` drilldowns. The one thing it does not edit is a drilldown chain that goes deeper than one level: it shows only the first level, so edit longer chains in the YAML file (see below).

On the Dashboards list, the bookmark icon on a dashboard (**Add to favorites**) puts it in a **Favorites** group at the top of your list. **Pin Dashboard** on the selected dashboard makes it your pinned dashboard: it gets a pin icon and sorts first. You can have one pinned dashboard at a time, so pinning another one asks whether to replace it.

### As YAML, with the CLI

A dashboard can live in a YAML file in your project, next to your pipelines. The file has a `name`, an optional `description`, a `filters:` list and a `charts:` list. It can also hold pipeline `steps:`, so one file can describe both the pipeline that builds your tables and the dashboard that reads them.

```yaml
name: Engineering Dashboard
description: Delivery health for every team

filters:
  - id: time_range
    variable: time_range
    type: select
    label: Time Range
    default: 30d
    options:
      - { label: 7d, value: 7d }
      - { label: 30d, value: 30d }
      - { label: 90d, value: 90d }

charts:
  - name: total_prs
    title: Total PRs
    tab: Overview
    grid: { x: 0, y: 0, w: 3, h: 2 }
    dsl: |
      source("gh.pr_enriched", time: opened_at)
        .since(@time, "[%time_range%]")
        .agg([count() as total])
        .chart(kpi, y: total, compare: opened_at, title: "Total PRs")
    drilldown_dsl: |
      source("gh.pr_enriched")
        .since(opened_at, "[%time_range%]")
        .sort([opened_at: desc])
        .select([repo, author, pr_title, opened_at])
        .limit(50)
```

Then publish it:

```bash
solidafy dashboard push environments/sandbox/pipelines/engineering.yaml
```

`dashboard push` matches an existing dashboard by `name`: if one exists it is updated in place and its existing chart ids are kept, otherwise a new dashboard is created. The other dashboard commands are:

| Command | What it does |
| --- | --- |
| `solidafy dashboard list` | Lists dashboards in the active environment with their id, draft or published state and chart count. |
| `solidafy dashboard pull [name] [--all] [-o yaml\|json]` | Writes dashboards to `environments/<env>/dashboards/`. The default YAML output is push-ready, so pull, edit, push is a round trip. |
| `solidafy dashboard push <file>` | Creates or updates the dashboard described by the file. |
| `solidafy dashboard delete <name\|id>` | Deletes a dashboard. |

You can also keep long queries in separate files. On any chart, `dsl_file: path` reads the query from a file and `drilldown_dsl_file: path` (or a list of paths) does the same for the drilldown. On a filter, `options_dsl_file: path` does it for `options_dsl`. Inside a DSL file, a line `#include shared/preamble.dsl` inlines another file. Paths are relative to the YAML file.

## Chart fields

Each entry under `charts:` accepts these fields:

| Field | Purpose |
| --- | --- |
| `name` | Identifier used for matching on push and in CLI output. |
| `title`, `subtitle` | Shown in the widget header. |
| `description` | Help text behind the info icon. Markdown is supported. |
| `tab` | The tab the chart belongs to. See [Tabs and grid layout](#tabs-and-grid-layout). |
| `grid` | Position and size: `{ x, y, w, h }`. |
| `dsl` | The chart query. |
| `drilldown_dsl` | What happens when someone clicks the chart. See [Drilldowns](/docs/dashboards/drilldowns). |
| `drilldown_mode` | `modal` (default) or `inline`. |
| `panes`, `default_pane_index` | Several views in one widget. See [Multi-pane widgets](#multi-pane-widgets). |
| `colors` | A list of colours (hex strings) to use for the chart's series. |
| `config` | Presentation extras: `columns` (friendly table headers), `default_sort`, and `quadrant` (scatter and bubble overlays). See [Tables](#tables) and [Scatter and bubble quadrants](#scatter-and-bubble-quadrants). |

## Tabs and grid layout

The dashboard is a 12-column grid. Every chart has `grid: { x, y, w, h }`: `x` is the starting column (0 to 11), `w` the width in columns (1 to 12), `y` the row and `h` the height in rows.

**Grid coordinates are per tab.** Each tab is laid out on its own, starting at `x: 0, y: 0`. If your Overview tab uses rows 0 to 16, the next tab still starts at `y: 0`. Carrying `y` on across tabs leaves a large empty gap at the top of the later tab.

A typical layout:

```yaml
charts:
  # Row 1: four KPI tiles, 3 columns each
  - { name: kpi_a, tab: Overview, grid: { x: 0, y: 0, w: 3, h: 2 }, dsl: "..." }
  - { name: kpi_b, tab: Overview, grid: { x: 3, y: 0, w: 3, h: 2 }, dsl: "..." }
  - { name: kpi_c, tab: Overview, grid: { x: 6, y: 0, w: 3, h: 2 }, dsl: "..." }
  - { name: kpi_d, tab: Overview, grid: { x: 9, y: 0, w: 3, h: 2 }, dsl: "..." }
  # Row 2: two half-width charts side by side
  - { name: trend, tab: Overview, grid: { x: 0, y: 2, w: 6, h: 4 }, dsl: "..." }
  - { name: split, tab: Overview, grid: { x: 6, y: 2, w: 6, h: 4 }, dsl: "..." }
  # A second tab starts again at y: 0
  - { name: detail, tab: Detail, grid: { x: 0, y: 0, w: 12, h: 5 }, dsl: "..." }
```

Rules of thumb that the validator also checks:

- No chart may extend past column 12 (`x + w <= 12`), and two charts on the same tab may not overlap.
- KPI tiles use `h: 2`. Tables read best at `w: 12`.
- If a chart has no `grid`, it gets a default spot (two charts per row, each 6 wide and 4 high). If a dashboard has tabs and a chart has no `tab`, it lands on the first tab.

Charts load lazily: a widget runs its query when it comes close to the visible part of the page, so long dashboards stay fast. Each widget header has **Refresh** and **Export CSV** actions, and line, area, bar and band charts with a declared granularity also get a **Granularity** picker (1m to 1mo) that changes the bucket size for that one widget.

## Chart types

The chart type is the first argument of `.chart(...)`. These are the types a dashboard draws:

| Type | Use it for | Main options |
| --- | --- | --- |
| `bar` | Comparing categories | `x`, `y` (one column or a list), `series`, `stack` |
| `line` | Trends over time | `x`, `y`, `series` |
| `timeseries` | Same as `line`; the usual choice with `x: @granularity` | `x`, `y`, `series`, `stack` |
| `area` | Trends with volume | `x`, `y`, `series`, `stack` |
| `pie`, `donut` | Share of a whole | `y` (the value), `series` (the slice label) |
| `scatter` | Correlation between two numbers | `x`, `y`, `series` |
| `bubble` | Scatter with a third number as dot size | `x`, `y`, `size`, `series` |
| `radar` | Comparing profiles across several dimensions | `x` (dimension), `y` (score), `series` |
| `funnel` | Stage-by-stage drop-off | `x` (stage), `y` (count) |
| `waterfall` | Cumulative gains and losses | `x`, `y` |
| `band` | A line with a lower and upper band, such as an expected range | `x`, `y`, `band: [lower_col, upper_col]` |
| `heatmap` | A value across two categories, such as day by hour | `x`, `y`, `value` |
| `boxplot` | Distribution per category | `x` (category) and `y` (raw values, quartiles are computed for you), or precomputed columns named `min`, `q1`, `median`, `q3`, `max` |
| `kpi` | One headline number | `y`, `compare`, `sparkline`, `target`, `thresholds`, `invert`, `unit`, `format` |
| `gauge` | One number against a range | `y`, `min`, `max`, `thresholds` |
| `leaderboard` | A ranked list with bars | `x` (label), `y` (value), `detail: [cols]` |
| `sankey` | Flows between nodes | `source`, `target`, `value` |
| `flow` | A tree or DAG of nodes with a metric each | `x` (node id), `parent`, `y: [metrics]` |

`composed` is also accepted and currently renders as a bar chart.

### Tables

There is no `table` chart type. To show rows as a table, leave `.chart(...)` off: a query that ends in `.select([...])` (or `.sort(...)`, `.limit(...)`) renders as a sortable, paginated table.

```dsl
source("gh.pr_enriched")
  .since(@time, "[%time_range%]")
  .group_by([author])
  .agg([count() as prs, round(avg(cycle_time_hours), 1) as avg_cycle])
  .sort([prs: desc])
  .select([author, prs, avg_cycle])
```

Use the chart's `config` to give the columns friendly headers and a starting sort:

```yaml
config:
  columns:
    avg_cycle: { label: Avg cycle (h), description: Hours from open to merge }
    prs: PRs
  default_sort: { column: prs, dir: desc }
```

### Options reference

All options are written as `name: value` after the chart type, for example `.chart(bar, x: team, y: [prs, merged], stack: true, title: "PRs by team")`.

| Option | Value | Applies to |
| --- | --- | --- |
| `x` | Column or expression | Most types |
| `y` | Column, aggregate, or a list `[a, b]` | Most types |
| `series` | Column whose values become separate series | Bar, line, area, pie, donut, scatter, bubble, radar |
| `stack` | `true` or `false` | Bar, area, timeseries |
| `title` | String | All |
| `color` | A colour string or a list of colours | All |
| `legend`, `tooltip` | `true` or `false` | All |
| `size` | Column for dot size | Bubble |
| `value` (or `z`) | Column for the cell value | Heatmap, sankey |
| `band` | `[lower_col, upper_col]` | Band |
| `min`, `max` | Number | Gauge (defaults 0 and 100) |
| `thresholds` | Two numbers, `[a, b]` | KPI, gauge |
| `target` | Number, `@variable.field`, or an aggregate | KPI |
| `invert` | `true` when lower is better | KPI |
| `compare` | The time column to compare against the previous period | KPI |
| `sparkline` | The time column to draw a small trend from | KPI |
| `unit` | String such as `"$"`, `"%"`, `"ms"`, `"hrs"` | KPI |
| `format` | `[duration]`, `[round, 0]`, `[percent, 2]` or `[currency, "USD"]` | KPI and value display |
| `detail` | List of extra columns to show per row | Leaderboard |
| `source`, `target` | Node columns | Sankey |
| `parent` | Parent id column | Flow |

### KPI cards

A KPI shows one number. Add `compare: <time column>` to show the change against the previous period of the same length, and `sparkline: <time column>` for a small trend line behind the number.

`thresholds: [green, red]` colours the card:

- Higher is better (the default): at or above `green` is good, at or above `red` is amber, below `red` is bad. So `green` should be the larger number.
- With `invert: true` (lower is better, such as cycle time or error rate): at or below `green` is good, at or below `red` is amber, above `red` is bad.

`target` draws a progress bar towards a goal. See [Goals and targets](#goals-and-targets) for pulling targets from a table instead of hard-coding them.

Gauges colour differently: below the first threshold is green, from the first threshold up is amber, and from the second threshold up is red. The defaults are `[70, 90]`.

### Scatter and bubble quadrants

Scatter and bubble charts can draw a 2 by 2 quadrant overlay from the chart's `config`:

```yaml
config:
  quadrant:
    xDivide: 50
    yDivide: 24
    labels:
      topLeft: Small but slow
      topRight: Big and slow
      bottomLeft: Small and fast
      bottomRight: Big and fast
```

`xMin`, `xMax`, `yMin` and `yMax` pin the axes to a fixed range. Without `xDivide` and `yDivide`, the split sits in the middle of the data.

### Sankey and flow

Most charts use `x`, `y` and `series`. Sankey and flow use node columns instead.

A sankey needs three columns: source, target and value. Build multi-level flows by computing each level separately and combining them with `union`:

```dsl
level1 = source("jira.issues_enriched")
  .group_by([project_name, state_name]).agg([count() as tickets])
  .select([project_name as source, state_name as target, tickets as value])
level2 = source("jira.issues_enriched")
  .group_by([state_name, category]).agg([count() as tickets])
  .select([state_name as source, category as target, tickets as value])
union([level1, level2])
  .chart(sankey, source: source, target: target, value: value, title: "Project to status to category")
```

A flow chart draws each row as a node, linked to its parent: `.chart(flow, x: node_id, parent: parent_id, y: [duration_ms])`. If the rows have `label`, `sublabel` or `status` columns, the nodes show them.

## The preamble pattern

Dashboard filters work by rewriting each chart's query before it runs (see [Filters](/docs/dashboards/filters)). For filters that inject a `.filter(...)`, the rewrite only touches the **last statement** of the query. If the last statement joins in the columns you filter on, the injected filter can land before the join, where those columns do not exist yet, and the chart fails.

The fix is to do joins in a named variable first (the "preamble") and keep the last statement a short chain that starts from that variable:

```dsl
base = source("gh.pr_enriched", time: opened_at, granularity: 1d)
  .select([pr_id, repo, author, opened_at, was_merged, cycle_time_hours])
  .join("enrich.developers", left_on: [author], right_on: [github_handle], type: inner)
  .filter(team != "Bot")

base
  .since(@time, "[%time_range%]")
  .filter(team == "[%team%]")
  .group_by([display_name, team])
  .agg([count() as prs])
  .chart(bar, x: display_name, y: prs, title: "PRs by engineer")
```

Two related rules:

- **The last statement must be free-standing.** `result = source(...)` on its own produces no output. End with `base` followed by a chain, or a bare `source(...)` chain.
- **Compute derived columns before `group_by`.** After a `group_by`, only the grouped columns and the aggregates exist.

## Time: @time and @granularity

Declare the time column and a default bucket size on the main `source(...)`:

```dsl
source("gh.pr_enriched", time: opened_at, granularity: 1d)
```

Then:

- `.since(@time, "[%time_range%]")` limits the chart to the window chosen in the dashboard's time filter. `@time` stands for the column you declared, so the same query works against tables whose time column has a different name.
- `x: @granularity` together with `.group_by([@granularity, ...])` buckets by the declared granularity.

The dashboard adjusts the bucket size to the selected window, so a 7-day view shows days and a year shows months:

| Window | Bucket |
| --- | --- |
| Less than 7 days | 1 hour |
| 7 to 92 days | 1 day |
| 93 to 183 days | 1 week |
| More than 183 days | 1 month |

This applies to windows written as a number plus a unit (`7d`, `90d`, `365d`). Named windows such as `mtd` or `ytd` keep the granularity written in the query.

```dsl
base
  .since(@time, "[%time_range%]")
  .group_by([@granularity, team])
  .agg([count() as prs])
  .chart(timeseries, x: @granularity, y: prs, series: team, stack: true)
```

Variables defined in the preamble keep whatever window you write into them. If a preamble variable needs a fixed lookback (for example daily totals over 90 days), write it as a plain duration on the real column, `.since(date, "90d")`.

## Goals and targets

Rather than hard-coding a target into a KPI, keep targets in a table and read them into a scalar variable. A variable whose name starts with `@` holds a single row, and `@name.column` reads one value from it:

```dsl
@goal = source("enrich.goals")
  .filter(metric == "cycle_time_hours")
  .select([target_value, threshold_green, threshold_red])

base = source("gh.pr_enriched", time: opened_at, granularity: 1d)
  .join("enrich.developers", left_on: [author], right_on: [github_handle], type: inner)
  .filter(team != "Bot")

base
  .since(@time, "[%time_range%]")
  .filter(was_merged == 1)
  .agg([round(avg(cycle_time_hours), 1) as avg_cycle])
  .chart(kpi, y: avg_cycle,
    target: @goal.target_value,
    thresholds: [@goal.threshold_green, @goal.threshold_red],
    invert: true, compare: opened_at, unit: "hrs", title: "Avg cycle time")
```

`enrich.goals` here is a table you maintain yourself, for example a seed table with one row per metric. Because `@goal` lives in the preamble, dashboard filters never change it.

## Multi-pane widgets

A single widget can hold several views behind a small tab strip: a trend, a breakdown and a detail table in one cell instead of three cells fighting for space. Set `panes:` on the chart; each pane is its own chart definition with its own `dsl` and `drilldown_dsl`.

```yaml
charts:
  - name: deploy-overview
    title: Deploys
    tab: Overview
    grid: { x: 0, y: 0, w: 12, h: 6 }
    panes:
      - title: By team
        dsl: |
          source("gh.deploys", time: deployed_at, granularity: 1d)
            .since(@time, "[%time_range%]")
            .group_by([@granularity, team])
            .agg([count() as deploys])
            .chart(timeseries, x: @granularity, y: deploys, series: team, stack: true)
        drilldown_dsl: |
          source("gh.deploys").filter(team == "${team}").sort([deployed_at: desc]).select([repo, deployed_at]).limit(50)
      - title: By repo
        dsl: |
          source("gh.deploys", time: deployed_at)
            .since(@time, "[%time_range%]")
            .group_by([repo])
            .agg([count() as deploys])
            .sort([deploys: desc])
            .limit(15)
            .chart(bar, x: repo, y: deploys)
      - title: Detail
        dsl: |
          source("gh.deploys", time: deployed_at)
            .since(@time, "[%time_range%]")
            .sort([deployed_at: desc])
            .select([deployed_at, repo, team, environment, status])
```

How panes behave:

- When `panes` is set, the outer chart's `dsl` is ignored. Each pane carries its own.
- `grid` and `tab` belong on the outer chart.
- Each pane's tab label is its `title` (it falls back to "Tab 1", "Tab 2" and so on).
- The first pane shows first. Set `default_pane_index: 1` on the outer chart to open on the second.
- Only the visible pane runs its query. A pane runs the first time you open it, and filters apply to whichever pane is showing.
- Drilldown state is per pane and resets when you switch panes.

Use dashboard tabs for different audiences or topics, and panes for different angles on the same metric.

## Testing checklist

Before you publish a dashboard, run through these:

1. **Validate the file.** `solidafy validate <file>` checks structure without touching the server: required fields, grid bounds and overlaps, filters that no chart uses, tab-scoped filters on tabs that do not exist, and drilldowns. `solidafy pipelines push` runs the same checks and refuses to push on errors.
2. **Run every query against live data.** `solidafy test <file>` runs each chart, each pane and each drilldown level with your filter defaults filled in, and reports PASS or FAIL per query. Drilldowns are tested with real values from the parent chart's first row. Add a chart name to test one chart: `solidafy test <file> "PR Trend"`.
3. **Check the filters.** Open the dashboard and change every filter. A chart that does not change when it should is not using the filter (see [Filters](/docs/dashboards/filters#pitfalls)).
4. **Check the time range.** Pick a short window and a long one and confirm the buckets and totals move.
5. **Click everything.** Every clickable chart should open a drilldown that explains the number you clicked.
6. **Publish and re-pull.** `solidafy dashboard push <file>`, then `solidafy dashboard pull <name>` to confirm what is stored matches what you meant.
