Manage parameters in charts
A parameter is a variable which you can change on the fly to control the visualization in your chart. For example, it allows you to change the time period via a selector.
Follow the instructions below to add parameters to your chart and control them with a selector.
Chart parameter limitations
-
The parameter affects only the chat which you apply it to.
-
If you have a parameter with the same name applied to a dataset, the chart parameter will be ignored.
For this example, we're going to use the Price chart on the first page of your Demo dashboard.
To add a parameter to your chart:
-
Select the chart you want to apply a parameter to and click
-
In the left pane under the dataset, click + → Parameter:
-
In the Add parameter window:
-
Name your parameter. For this example, let's call it
scale
. -
Select the parameter Type. You can select the following parameter types:
For this example, select
String
. -
Specify the parameter's Default value. This is a required field. It's useful when you have no parameter value set in the dashboard, chart URL, or chart settings.
For this example, type the following:
year
.This is what your configuration should look like:
-
Click Add. You'll see your parameter in the left pane:
-
-
Click Add.
-
Add a calculated field to integrate the parameter into your chart's X axis:
-
In the left pane under the dataset, click + → Field.
-
Name your new field Period and write the following formula:
DATETRUNC([Booking Start], [scale])
-
Click Create.
-
Drag and drop the Period field to the X axis. You should see the following:
-
Click Apply
-
-
Add a selector to apply the new parameter to your chart:
-
Click Add → Selector.
-
Toggle Manual input.
-
Under Field or parameter name, type
Scale
. -
Under Default value, click Not selected.
-
In the Possible values window, add the following items to the list:
-
year
-
month
-
week
-
day
The result should look like this:
-
-
Click Apply.
-
To select the default value, select
year
from the Not defined drop-down menu. -
Under Title, type
Period:
.Your complete selector configuration should look like this:
-
Click Add.
-
Place the selector under the chart:
-
In the upper-right corner, click Save.
-
-
Select different parameter values from the chart and observe how the level of detail changes on the chart: from
year
today
.