# Reference lines

A reference line is a line intersecting the chart area from a given point on the measure axis. You can use a reference line to indicate a certain level of chart data. The reference line is only drawn if it falls within the current range of the measure axis. You can have several reference lines in the same chart. Reference lines are available in the following visualization types:

* Bar chart
* Box plot
* Distribution plot
* Gauge
* Histogram
* Line chart
* Scatter plot
* Waterfall chart

You can either set the reference line value to an absolute numeric value, or enter an arbitrary numeric expression, see examples below



## The refLine object

Reference lines are defined in the refLine object. You can have several reference lines defined for the same visualization.

Example: Empty refLine object

```
"refLine": {
    "refLines": []
  }
```

The properties of the reference line are set in an array (refLines) and can consist of the following properties:

[](https://help.qlik.com/en-US/sense-developer/Subsystems/Mashups/Content/Sense_Mashups/Create/Visualizations/reference-lines.htm)

#### show

Set to true to display the reference line in the visualization.

Default: false

[](https://help.qlik.com/en-US/sense-developer/Subsystems/Mashups/Content/Sense_Mashups/Create/Visualizations/reference-lines.htm)

#### label

Reference line label as a string.

You can also set a label property inside the refLineExpr object and this defines the label of the value. It follows the following syntax when displayed in the visualization: refLines.label (refLines.refLineExpr.label).

![Example refLine object with a label above the reference](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/Mashups/Content/Resources/Images/on-the-fly-example-reference-line-labels.png)

[](https://help.qlik.com/en-US/sense-developer/Subsystems/Mashups/Content/Sense_Mashups/Create/Visualizations/reference-lines.htm)

#### paletteColor

Defines the reference line color. It can either be as an index number from the color palette (0-15) or it can be a HEX color code. If the paletteColor property is not defined, the color defaults to black. If you are using the color property to define a color that is not in the color palette, the index property should be "index": -1.

paletteColor properties

| Name | Type | Description |
| --- | --- | --- |
| index | Integer | Index in the palette.<br><br>The default Qlik Sense color palette:<br><br><ul> <li><span>-1</span>: set to use custom color that is not in the palette.</li> <li><span>0</span>: No color</li> <li><span>1</span>: White, HEX: <span>#ffffff</span></li> <li><span>2</span>: Light green, HEX: <span>#46c646</span></li> <li><span>3</span>: Green, HEX: <span>#276e27</span></li> <li><span>4</span>: Light blue, HEX: <span>#b6d7ea</span></li> <li><span>5</span>: Blue, HEX: <span>#7db8da</span></li> <li><span>6</span>: Dark blue, HEX: <span>#4477aa</span></li> <li><span>7</span>: Purple, HEX: <span>#8e477d</span></li> <li><span>8</span>: Yellow, HEX: <span>#ffcf02</span></li> <li><span>9</span>: Orange, HEX: <span>#f8981d</span></li> <li><span>10</span>: Red, HEX: <span>#f93f17</span></li> <li><span>11</span>: Brown, HEX: <span>#633d0c</span></li> <li><span>12</span>: Light gray, HEX: <span>#b0afae</span></li> <li><span>13</span>: Gray, HEX: <span>#7b7a78</span></li> <li><span>14</span>: Dark gray, HEX: <span>#545352</span></li> <li><span>15</span>: Black, HEX: <span>#000000</span></li> </ul><br><br>Default: 6 |
| color | String | Color as HEX string.<br><br>Mandatory if "index": "-1". |

[](https://help.qlik.com/en-US/sense-developer/Subsystems/Mashups/Content/Sense_Mashups/Create/Visualizations/reference-lines.htm)

#### refLineExpr

Defines the actual value of the reference line

refLineExpr properties

| Name | Type | Description |
| --- | --- | --- |
| value | - | Can be an absolute numeric value or an arbitrary numeric expression<br><br>Example: Absolute numeric value<br><br>```<br>"refLineExpr": {<br>"value": 2<br>}<br>```<br><br>Example: Arbitrary numeric expression<br><br>```<br>"refLineExpr": {<br>"value": {<br>"qValueExpression": {<br>"qExpr": "=Count(distinct ID)/Count(distinct [Date.autoCalendar.YearMonth])"<br>}<br>}<br>}<br>``` |
| label | String Expression Container | Defines the label of the value as a string or as an expression.<br><br>You can also set a label property inside the refLines object and this defines the label of the reference line. It follows the following syntax when displayed in the visualization: refLines.label (refLines.refLineExpr.label). |

## Using an absolute numeric value

This example defines a reference line by an absolute numeric value. Set the absolute numeric value of reference line : "refLineExpr": { "value": 2, "label": "2" }. Then set "show": true to enable the reference line. Define the color of the reference line: "paletteColor": { "index": 7, "color": "#8e477d" }. Note how the label property is empty.

"refLine": { "refLines": [ { "show": true, "label": "", "paletteColor": { "index": 7, "color": "#8e477d" }, "refLineExpr": { "value": 2, "label": "2" } } ] }

Result

![Example refLine using an absolute value](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/Mashups/Content/Resources/Images/on-the-fly-example-reference-line-absolute-numeric-value.png)

## Using an arbitrary numeric expression

You can use an arbitrary numeric expression as a reference line. This means that the value property includes a value expression instead of a number: "value": { "qValueExpression": { "qExpr": "=Count(distinct ID)/Count(distinct [Date.autoCalendar.YearMonth])" } }.

Note how the label property now has a value.

"refLine": { "refLines": [ { "show": true, "label": "Avg", "paletteColor": { "index": 7, "color": "#8e477d" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count(distinct ID)/Count(distinct [Date.autoCalendar.YearMonth])" } }, "label": { "qStringExpression": { "qExpr": "=Count(distinct ID)/Count(distinct [Date.autoCalendar.YearMonth])" } } } } ] }

Result

![Example refLine using an expression](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/Mashups/Content/Resources/Images/on-the-fly-example-reference-line-arbitrary-numeric-expression.png)

## Defining multiple reference lines

You can use multiple reference lines in your visualization. You can select to keep them in the code but to hide them from being shown in the visualization by setting "show": false, as demonstrated on the last reference line in the example below.

"refLine": { "refLines": [ { "show": true, "label": "Pars this year", "paletteColor": { "index": -1, "color": "#91c26a" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Pars'}&gt;}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Pars'}&gt;}NetScoreName)" } } } }, { "show": true, "label": "Birdies this year", "paletteColor": { "index": -1, "color": "#52a2cc" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Birdies'}&gt;}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Birdies'}&gt;}NetScoreName)" } } } }, { "show": true, "label": "Boogies this year", "paletteColor": { "index": 9, "color": "#f8981d" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Boogies'}&gt;}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Boogies'}&gt;}NetScoreName)" } } } }, { "show": false, "label": "Double Boogies this year", "paletteColor": { "index": 9, "color": "#f8981d" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'2 Boogies'}&gt;}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({&lt;[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'2 Boogies'}&gt;}NetScoreName)" } } } } ] }

Result

![Example of multiple reference lines with labels and specific colors](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/Mashups/Content/Resources/Images/on-the-fly-example-reference-line-multiple-lines.png)