Skip to main content

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:

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" } } ] }

Example refLine using an absolute value

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])" } } } } ] }

Example refLine using an expression

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({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Pars'}>}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Pars'}>}NetScoreName)" } } } }, { "show": true, "label": "Birdies this year", "paletteColor": { "index": -1, "color": "#52a2cc" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Birdies'}>}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Birdies'}>}NetScoreName)" } } } }, { "show": true, "label": "Boogies this year", "paletteColor": { "index": 9, "color": "#f8981d" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Boogies'}>}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'Boogies'}>}NetScoreName)" } } } }, { "show": false, "label": "Double Boogies this year", "paletteColor": { "index": 9, "color": "#f8981d" }, "refLineExpr": { "value": { "qValueExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'2 Boogies'}>}NetScoreName)" } }, "label": { "qStringExpression": { "qExpr": "=Count({<[Date.autoCalendar.YearsAgo]={'0'},NetScoreName={'2 Boogies'}>}NetScoreName)" } } } } ] }

Example of multiple reference lines with labels and specific colors