Defaults for tokens

Typically, the user sets a token's value by interacting with a dashboard component, such as clicking a section of a pie chart or selecting a value from a dropdown list. A token's default value exists when the dashboard loads initially, before the user interacts with any dashboard component. The token value changes as users interact with dashboard components.

With no default token value, visualizations that rely on that token are initially blank and display Set token value to render visualization until a user interacts with a dashboard component that sets the token. Therefore, you may define default token values to ensure that visualizations display data on initial dashboard loading. You can also define default values for tokens that are not set by interacting with a dashboard component.

The following example dashboard has a dropdown, Severity Level, which sets a token named severity_level_token used to render visualizations. When there is no default value set for the token, the dashboard loads with no value for severity_level_token and visualizations do not render.

A dashboard with a Severity Level dropdown displaying "Select a value" and 4 visualizations. All visualizations display "Set token value to render visualization" and no data.The following shows the same dashboard when the default value for severity_level_token is defined as All. When the dashboard loads, the visualizations render using the token value of All.

A dashboard with a Severity Level dropdown set to All and 4 visualizations. All visualizations display data.

You can set a token's default value in one of the following:

  • tokens sub-stanza in the defaults stanza

  • Visualization with a Set tokens interaction

  • Input

defaults stanza

defaults is a top-level stanza in the dashboard definition. The defaults stanza may contain the following sub-stanzas:

  • dataSources

  • visualizations

  • tokens

This topic only discusses configuring defaults for tokens. For configuring data source and visualization defaults, see Defaults for data sources and visualizations.

You can define a default value for a token by directly editing the tokens sub-stanza in the source code editor. The following shows an example of a defaults stanza where a token named location is set to a default value of "Toronto":
"defaults": {
        "tokens": {
            "default": {
                "location": {
                    "value": "Toronto"
                }
            }
        }
}

Visualization with a Set tokens interaction

You can set a token's default value by selecting a visualization with an interaction that sets that token, and entering the desired value in the Default value field. This updates the tokens sub-stanza without needing to use the source code editor.

Input

For a token associated with an input, you can set the default value by selecting the input and entering the desired value under Default selected values. This updates the defaultValue option for that input.

The following shows the source code for a dropdown where the associated token, location, has a default value of "vancouver":
"inputs": {
        "input_yfqIDwjh": {
            "options": {
                "defaultValue": "vancouver",
                "items": [
                    {
                        "label": "All",
                        "value": "*"
                    },
                    {
                        "label": "Vancouver",
                        "value": "vancouver"
                    },
                    {
                        "label": "Seattle",
                        "value": "seattle"
                    }
                ],
                "token": "location"
            },
            "title": "Location",
            "type": "input.dropdown"
        }
    }