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

# Reference Line

> Add a reference line inside a chart

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/reference_line.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=79cac6c974bfd9f474dabc96a29a8031" alt="Horizontal Target Line" width="1000" height="430" data-path="images/components/reference_line/reference_line.png" />

```liquid theme={null}
{% line_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line 
        y=3500000 
        label="Target" 
        color="red" 
    /%}
{% /line_chart %}
```

## Examples

### Horizontal Target Line

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/reference_line.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=79cac6c974bfd9f474dabc96a29a8031" alt="Horizontal Target Line" width="1000" height="430" data-path="images/components/reference_line/reference_line.png" />

```liquid theme={null}
{% line_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line 
        y=3500000 
        label="Target" 
        color="red" 
    /%}
{% /line_chart %}
```

### Vertical Line at Date

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/example-1.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=a30f0f1a065fb116bf4ec7f1780dd39d" alt="Vertical Line at Date" width="1000" height="430" data-path="images/components/reference_line/example-1.png" />

```liquid theme={null}
{% line_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line 
        x="2021-06-01" 
        label="Product Launch" 
        color="green" 
    /%}
{% /line_chart %}
```

### Reference Lines from Data

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/example-2.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=f4e48e8b78331fc858a2073c2a63d419" alt="Reference Lines from Data" width="1000" height="430" data-path="images/components/reference_line/example-2.png" />

````liquid theme={null}
```sql ref_lines
select 2500000 as ref, 'Min Target' as ref_label
union all
select 4000000, 'Stretch Goal'
```

{% bar_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line 
        data="ref_lines" 
        y="ref" 
        label="ref_label" 
    /%}
{% /bar_chart %}
````

### Custom Label Styling

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/example-3.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=90de41fdbce178fcedeb917fd4b26389" alt="Custom Label Styling" width="1000" height="430" data-path="images/components/reference_line/example-3.png" />

```liquid theme={null}
{% line_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line 
        y=3000000 
        label="Threshold" 
        color="orange"
        label_options={
            position="above_start"
            background_color="orange"
            color="white"
            padding=4
        }
        line_options={
            type="dashed"
            width=2
        }
    /%}
{% /line_chart %}
```

### Multiple Reference Lines

<img src="https://mintcdn.com/evidence/ImoR9rIJqT9N0Esa/images/components/reference_line/example-4.png?fit=max&auto=format&n=ImoR9rIJqT9N0Esa&q=85&s=50d7427db251919d5b6bdd6cc4576ef4" alt="Multiple Reference Lines" width="1000" height="430" data-path="images/components/reference_line/example-4.png" />

```liquid theme={null}
{% line_chart
    data="demo.daily_orders"
    x="date"
    y="sum(total_sales)"
    date_grain="month"
%}
    {% reference_line y=2500000 label="Min Target" color="red" /%}
    {% reference_line y=4500000 label="Stretch Goal" color="green" /%}
{% /line_chart %}
```

## Attributes

<ResponseField name="data" type="string">
  Query name to use for calculating dynamic reference values
</ResponseField>

<ResponseField name="label" type="string">
  Text label to display on the reference line
</ResponseField>

<ResponseField name="x" type="string | number">
  X-axis value for a vertical reference line (e.g., a date or category)
</ResponseField>

<ResponseField name="y" type="string | number">
  Y-axis value for a horizontal reference line (e.g., a target or threshold)
</ResponseField>

<ResponseField name="x1" type="string | number">
  Starting x-coordinate for a sloped line
</ResponseField>

<ResponseField name="y1" type="string | number">
  Starting y-coordinate for a sloped line
</ResponseField>

<ResponseField name="x2" type="string | number">
  Ending x-coordinate for a sloped line
</ResponseField>

<ResponseField name="y2" type="string | number">
  Ending y-coordinate for a sloped line
</ResponseField>

<ResponseField name="color" type="string">
  Color of the reference line
</ResponseField>

<ResponseField name="label_options" type="options group">
  Styling options for the label

  **Example:**

  ```
  label_options={
    position = "above_end"
    align = "left"
    color = "string"
    background_color = "string"
    padding = 0
    fmt = "date"
    hide_value = true
    border = {
      width = 0
      type = "solid"
      color = "string"
      radius = 0
    }
    text = {
      size = 0
      bold = true
      italic = true
    }
  }
  ```

  **Attributes:**

  * position: `string`
    * **Allowed values:**
      * `above_end`
      * `above_start`
      * `above_center`
      * `below_end`
      * `below_start`
      * `below_center`
  * align: `string`
    * **Allowed values:**
      * `left`
      * `center`
      * `right`
  * color: `string`
  * background\_color: `string`
  * padding: `number`
  * fmt: `string` - Format the label value. Defaults to series or axis fmt.
    * **Allowed values:** See [Value Formatting](/core-concepts/value-formatting) for all available formats.
  * hide\_value: `boolean`
  * border: `options group`
    * **Options:**
      * width: `number`
      * type: `string`
        * **Allowed values:**
          * `solid`
          * `dashed`
          * `dotted`
      * color: `string`
      * radius: `number`
  * text: `options group`
    * **Options:**
      * size: `number`
      * bold: `boolean`
      * italic: `boolean`
</ResponseField>

<ResponseField name="line_options" type="options group">
  Styling options for the line itself

  **Example:**

  ```
  line_options={
    color = "string"
    width = 0
    type = "solid"
    opacity = 0
  }
  ```

  **Attributes:**

  * color: `string`
  * width: `number` - Width of the line
  * type: `string`
    * **Allowed values:**
      * `solid`
      * `dashed`
      * `dotted`
  * opacity: `number` - Between 0 and 1
</ResponseField>

<ResponseField name="symbols" type="options group">
  Symbol shapes to display at line endpoints

  **Example:**

  ```
  symbols={
    start = {
      shape = "circle"
      size = 0
    }
    end = {
      shape = "circle"
      size = 0
    }
  }
  ```

  **Attributes:**

  * start: `options group`
    * **Options:**
      * shape: `string`
        * **Allowed values:**
          * `circle`
          * `emptyCircle`
          * `rect`
          * `roundRect`
          * `triangle`
          * `diamond`
          * `pin`
          * `arrow`
          * `none`
          * `image://`
          * `path://`
      * size: `number`
  * end: `options group`
    * **Options:**
      * shape: `string`
        * **Allowed values:**
          * `circle`
          * `emptyCircle`
          * `rect`
          * `roundRect`
          * `triangle`
          * `diamond`
          * `pin`
          * `arrow`
          * `none`
          * `image://`
          * `path://`
      * size: `number`
</ResponseField>

## Allowed Parents

* [area\_chart](/components/area_chart)
* [bar\_chart](/components/bar_chart)
* [bubble\_chart](/components/bubble_chart)
* [combo\_chart](/components/combo_chart)
* [horizontal\_bar\_chart](/components/horizontal_bar_chart)
* [line\_chart](/components/line_chart)
* [scatter\_chart](/components/scatter_chart)
