# Dashboard

<Callout>
  Reports, Charts, Dashboards are intended to be created and modified through
  the user interface. The file representation is for checking errors during
  validation.
</Callout>

Each dashboard must be stored as **dashboard_name.dashboard** YAML file:

```yaml
dashboard: dashboard_name
title: ''
description: ''
access_roles:
- role
- role

parameters:
- filter: f1
  label: 'label'
  description: ''
  result: string
  suggest_model_dimension: model_name.field_path
  conditions:
  - f\`%a\`

tiles:
- title: 'tile title'
  description: ''
  model: model_name
  select:
  - field_path
  - field_path
  - field_path
  parameters:
  - apply_to: field_path
    listen: f1
  - apply_to: field_path
    conditions:
    - f\`> 100\`
  sorts: field_path desc, field_path, ...
  limit: 500
  type: chart_type
  data:
    x_field: field_path
    y_fields:
    - field_path
    - field_path
    multi_field: field_path
    size_field: field_path
    pivot_rows:
    - field_path
    pivot_columns:
    - field_path
    pivot_values:
    - field: field_path
  options:
    x_axis:
      scale: false
    y_axis:
    - scale: false
    - scale: false
    series:
    - data_field: field_path
      y_axis_index: 0
      type: chart_type
    first_column_width: 235
    value_columns_width: 181
  plate:
    plate_width: 8
    plate_height: 12
    plate_x: 0
    plate_y: 0
```

## Reference

### Dashboard

| Name         | Type                                                           | Default | Description                                                                  |
| ------------ | -------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------- |
| dashboard\*  | string                                                         | -       | Dashboard name                                                               |
| title        | string                                                         | -       | Dashboard title in UI                                                        |
| description  | string                                                         | -       | Dashboard description in UI                                                  |
| access_roles | string []                                                      | -       | If specified, only users with the listed roles will have access to Dashboard |
| parameters   | [Top Filter []](/content/docs/reference/parameters#top-filter) | -       | Begin a section of dashboard parameters                                      |
| tiles\*      | [Tile []](/content/docs/reference/dashboard#tile)              | -       | Begin a section of tiles                                                     |

### Tile

| Name        | Type                                 | Default | Description                                                                                                     |
| ----------- | ------------------------------------ | ------- | --------------------------------------------------------------------------------------------------------------- |
| title\*     | string                               | -       | Tile title                                                                                                      |
| description | string                               | -       | Tile description in UI                                                                                          |
| model\*     | string                               | -       | Model name                                                                                                      |
| select\*    | string []                            | -       | List of selected fields                                                                                         |
| parameters  | [Tile Parameter []](#tile-parameter) | -       | Begin a section of tile parameters                                                                              |
| sorts       | string                               | -       | A way to sort data                                                                                              |
| limit       | number                               | 500     | Limit the number of rows                                                                                        |
| type\*      | enum                                 | -       | <ul><li>table</li><li>pivot_table</li><li>line</li><li>scatter</li><li>bar</li><li>single</li><li>pie</li></ul> |
| data        | [Tile Data](#tile-data)              | -       |                                                                                                                 |
| options     | [Tile Options](#tile-options)        | -       |                                                                                                                 |
| plate       | [Tile Plate](#tile-plate)            | -       | `only for dashboard tiles`                                                                                      |

### Tile Parameter

Tile parameter must have **listen**, **conditions** or **fractions**.

| Name       | Type                                                       | Default | Description                                                               |
| ---------- | ---------------------------------------------------------- | ------- | ------------------------------------------------------------------------- |
| apply_to\* | string                                                     | -       | Field or Filter name                                                      |
| listen     | string                                                     | -       | `only for dashboard tiles` <br/> Specify dashboard parameter to listen to |
| conditions | string []                                                  | -       | `for parameters mapped to Malloy Model` <br/> List of filter expressions  |
| fractions  | [Fraction []](/content/docs/reference/parameters#fraction) | -       | `for parameters mapped to Store Model` <br/> List of fractions            |

### Tile Data

| Name          | Type                                                       | Default | Description                                                                                                     |
| ------------- | ---------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------- |
| x_field\*\*   | string                                                     | -       | `for non-tables` One of selected fields (dimension) to get the X coordinate                                     |
| y_fields\*\*  | string []                                                  | -       | `for non-tables` One or more of selected fields (measure or calculation) to get series data                     |
| multi_field   | string                                                     | -       | `for non-tables` One of selected fields (dimension) for additional grouping of series data based on field value |
| size_field    | string                                                     | -       | `for scatter` One of selected fields to set size of data point                                                  |
| pivot_rows    | string []                                                  | -       | `for pivot_table` Zero or more of selected fields (dimensions)                                                  |
| pivot_columns | string []                                                  | -       | `for pivot_table` Zero or more of selected fields (dimensions)                                                  |
| pivot_values  | [Data Pivot Values Element []](#data-pivot-values-element) | -       | `for pivot_table` One or more elements                                                                          |

### Data Pivot Values Element

| Name    | Type   | Default | Description                                     |
| ------- | ------ | ------- | ----------------------------------------------- |
| field\* | string | -       | One of selected fields (measure or calculation) |

### Tile Options

| Name                | Type                                                 | Default | Description       |
| ------------------- | ---------------------------------------------------- | ------- | ----------------- |
| x_axis              | [Options X Axis](#options-x-axis)                    | -       |                   |
| y_axis              | [Options Y Axis Element []](#options-y-axis-element) | -       |                   |
| series              | [Options Series Element []](#options-series-element) | -       |                   |
| first_column_width  | integer                                              | 230     | `for pivot_table` |
| value_columns_width | integer                                              | 210     | `for pivot_table` |

### Options X Axis

| Name  | Type    | Default | Description                                                              |
| ----- | ------- | ------- | ------------------------------------------------------------------------ |
| scale | boolean | false   | "false" to start X Axis from Zero, "true" to start X Axis from Min value |

### Options Y Axis Element

| Name  | Type    | Default | Description                                                              |
| ----- | ------- | ------- | ------------------------------------------------------------------------ |
| scale | boolean | false   | "false" to start Y Axis from Zero, "true" to start Y Axis from Min value |

### Options Series Element

| Name            | Type    | Default | Description                                                             |
| --------------- | ------- | ------- | ----------------------------------------------------------------------- |
| data_field\*\*  | string  | -       | `for Dashboard or Chart tile options only` <br/> One of y_fields values |
| data_row_id\*\* | string  | -       | `for Report's options only` <br/> One of row_ids with show_chart "true" |
| y_axis_index    | integer | 0       | 0 (Y Axis Left) or 1 (Y Axis Right)                                     |
| type            | enum    | -       | <ul><li>line</li><li>bar</li></ul>                                      |

### Tile Plate

| Name         | Type    | Default | Description                                                              |
| ------------ | ------- | ------- | ------------------------------------------------------------------------ |
| plate_width  | integer | 8       | Plate width (1 to 24)                                                    |
| plate_height | integer | 12      | Plate height (min is 1)                                                  |
| plate_x      | integer | 0       | X coordinate of plate's top left corner on the dashboard grid (0 to 23)  |
| plate_y      | integer | 0       | Y coordinate of plate's top left corner on the dashboard grid (min is 0) |
