How to create vertical reference lines

Looker visualization options let you customize your visualization, including adding reference lines . The reference line options are static value, median, average (mean), maximum, minimum, and range, which can be selected in the Edit Visualizationsettings.

But what if you want to use vertical reference lines in a graph? For example, what if you want to visualize the various stages of a product launch on specific dates against the orders that were placed during that period?

The solution

Using table calculations , you can create vertical bars that you can reference in graphs. The vertical lines will appear like those in the following example.

The following example is based on an Explore with Orders Countgrouped by Orders Created Date.

To create a vertical reference line:

  1. Create a table calculation that references the data points in the visualization that you want to highlight with vertical reference lines. This example of a use case uses the following expression to create vertical reference lines to mark stages in the product launch dates using the Orders Created Date:
    if(
          to_string(${orders.created_date}) = "2019-12-21" OR
          to_string(${orders.created_date}) = "2019-12-14" OR
          to_string(${orders.created_date}) = "2019-12-07"
          ,
          max(${orders.count})+1, null
          )
  2. Next, apply the following sections in the visualization Editmenu:
    • In the Seriesmenu , set the visualization Typefor the table calculation to Column.
    • In the Xmenu , change Scale Typeto Ordinal.
    • In the Plotmenu , make sure Series Positioningis not set to Stacked Percentage.

The resulting visualization displays the line representing the number of orders placed over time, and the vertical bars produced by the Vertical reference linetable calculation mark the launch stages of the product over time — beginning, middle, and end:

Create a Mobile Website
View Site in Mobile | Classic
Share by: