Timeline charts help you visualize the relationship between groups of events so you can compare the timespans over which these events took place. The timeline visualization works with numbers as well, as described later in this section.
You can choose to use a timeline visualization by clicking the ellipsis (…) in the Visualization bar and choosing Timeline. Then you can use the visualization options for editing timeline charts, as described on this page. The visualization option menu can be accessed by clicking the gear in the upper right corner of the visualization tab.
The timeline chart below shows the timespan between a customer’s first order date and the customer’s most recent order date. In addition, each timespan is colored to indicate the number of orders that the customer has placed.
Timeline visualizations are based on fields in the Data section, so the fields must be in a particular order. Ignoring any fields that are hidden from the visualization, the timeline needs the following fields (in order from left to right):
- Label field: A string field, such as a name.
- Detail field: A second, optional string field, which allows you to combine each row of the timeline visualization into categories. See Displaying Individual or Multiple Bars per Row for more detail.
- Start field: A start date or number.
- End field: An end date or number.
- Magnitude field: An optional number field, which determines the bar color on a continuum between the two colors specified in the visualization options. See Using Colors for additional information and other options using colors and labels.
Using Timeline Visualizations Without Dates
Note that timeline charts can be helpful for information other than dates. For example, the timeline visualization below lists several airlines, each with a bar where:
- The bar starts at the airline’s on-time flight count
- The bar ends at the airline’s total flight count
- The bar’s color indicates the airline’s on-time percentage as a magnitude value
The magnitude coloring helps illustrate that although an airline may have a large difference between its on-time flight count and its total flight count, it may have a good on-time percentage. For example, Southwest has a wide bar but also has the best percentage of on-time flights, as shown by the purple bar showing its on-time percentage. You can hover over a bar to see the data that the bar represents, including:
- The beginning value of the bar
- The ending value of the bar
- The value represented by the color of the bar (if any)
Displaying Individual or Multiple Bars per Row
If you turn on Group Bars by Label, all records that share the same label value appear as individual bars on the same row in the visualization. For example, the data below has a label field indicating the age tier. Each age tier has only one row in the visualization, with one or more records displayed as bars on that age tier’s row:
Alternatively, you can display each record bar on its own row by turning off the Group Bars by Label option. In this case, the visualization will have multiple rows with the same label value, as shown below:
For timeline visualizations, the color of a bar can mean different things, depending on your data:
- Magnitude value: Each bar’s color is within a continuum and illustrates the magnitude value for the bar. To set this up, include a magnitude field in your query and specify a continuous palette (one that shades from one color to another, such as the sequential and diverging palettes in Looker’s color collections) in the visualization options.
- Detail value: Each bar’s color indicates its value in the detail field. To set this up, include a detail field in your data and choose a categorical palette (one that has multiple individual colors) in the visualization options. (If you don’t have a magnitude field, you can select a continuous palette and the colors will refer to the values in the detail field. But if you do have a magnitude field and select a continuous palette, the colors will always apply to the magnitude field.)
- In all other cases, the bar colors use a repeating pattern of the colors you select in the visualization options.
For example, below we have two different visualizations of the same customer data. The data includes a detail field (Traffic Source) and a magnitude field (Lifetime Orders). In this first example, we have selected a continuous palette. Since we have a magnitude field, the color continuum indicates the magnitude. The legend shows how many lifetime orders the colors on each end of the color continuum represent:
As a second example, below we have selected a categorical palette, so the colors indicate the values in the detail field. This is the same data as above, but now the legend shows which traffic source is represented by each color:
Finally, if we remove both the detail and magnitude fields, the colors simply cycle through the palette chosen in the visualization options:
The Bar Colors section lets you define the color palette for the chart.
Selecting a Color Collection and Palette
Choose a color collection from the Collection drop-down menu. A collection allows you to create themed visualizations and dashboards that look good together. You can see all the palettes in each of Looker's built-in color collections on the Color Collections documentation page. Your Looker admin may also create a custom color collection for your organization.
Once you select a color collection, the Palette section will update with a palette from that collection. If you'd like to change to a different palette in the color collection, click the color palette, which opens the palette picker. From there, you can view and select from all the palettes in the collection.
Choosing the Type of Palettes
If you use a sequential or diverging palette, each bar is colored on a scale along the palette. If you change to a categorical palette (a palette composed of multiple individual colors), colors are assigned to each bar in order. The first bar is assigned the first color, and so on. If there are more bars than colors listed, the colors repeat from the beginning of the palette.
Creating a Custom Color Palette
To create a custom color palette, first select the Custom tab on the palette picker. You can edit your palette in several ways:
- Click on one of the colors present to edit it.
- Click the + or - buttons below the color palette to add a color to the end of the palette or remove a selected color. When you add a color to the end of a sequential or diverging palette, Looker automatically creates a scale between that color and the previous one.
- Click EDIT ALL at the bottom right of the menu to use a comma-separated list of color values.
To change a selected color, or edit all colors at once, you can input hex strings, such as
#2ca6cd, or CSS color names, such as
mediumblue, into the color value box at the bottom of the menu.
You can also click the color wheel to the right of the color value box to bring up a color picker, which you can use to select a color. The corresponding hex value for that color appears in the color value box:
If you click EDIT ALL, you'll see that the color value box is populated with all the hex codes of the color palette you've chosen or customized. Copying and pasting this list is the best way to copy custom color palettes from one chart to another.
Select Reverse colors to reverse the palette. For a sequential or diverging palette, each bar is colored on a scale along the palette in reverse order, starting with the color at the right end of the palette and moving to the left. For a categorical palette, this would apply the colors in the palette to each bar in reverse order, starting with the last color in the palette.
Group Bars by Label
The Group Bars by Label option lets you determine whether the visualization should display each record bar in its own row, or if the record bars for each label value should all be in the same row. See Displaying Multiple Bars per Row.
Label Size sets the font size of the labels, from Tiny to Huge.
Value Format specifies the number or date format of the value. The parameter accepts Excel-style formatting. If no formatting is specified, the value will be displayed in the format of the underlying dimension or measure.
You can read Excel’s complete guide about how to specify these formats in their documentation. However, color formatting is not currently supported in Looker.
The Adding Custom Formatting to Numeric Fields documentation page provides more information on how to use custom formatting.
Using this field, you also can specify the formatting of date values. Some of the most common formatting options are shown here:
||Month as a number with no leading zero. May is shown as "5".|
||Month as a number with a leading zero when appropriate. May is shown as "05".|
||Month as an abbreviation (Jan to Dec).|
||Month as a full name (January to December).|
||Month as a single letter (J to D).|
||Day as a number without a leading zero.|
||Day as a number with a leading zero when appropriate.|
||Day as an abbreviation (Sun to Sat).|
||Day as a full name (Sunday to Saturday).|
||Year as a two-digit number.|
||Year as a four-digit number.|
||Hour as a number without a leading zero.|
||Hour as a number with a leading zero when appropriate. If the format contains AM or PM, the hour is based on the 12-hour clock. Otherwise, the hour is based on the 24-hour clock.|
||Minute as a number without a leading zero.
||Minute as a number with a leading zero when appropriate.
||Second as a number without a leading zero.|
||Second as a number with a leading zero when appropriate. If you want to display fractions of a second, use a number format that resembles h:mm:ss.00.|
||Hour using a 12-hour clock. Excel displays "AM" or "A" for times from midnight until noon and "PM" or "P" for times from noon until midnight.|
Show Legend lets you display or hide a legend at the bottom of the visualization.