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