Table of Contents generated with DocToc
Parameters are a feature added in HENGSHI SENSE 3.2.
Parameters are designed for parameterized control of the application. With parameters, we can achieve:
Previously, application version functions that required changes in multiple places can now be implemented by modifying in just one place.
Click Create New Parameter
on the Parameters
page to pop up the Create New Parameter
dialog.
The parameter type can be: text, number, date, time.
Each parameter must specify a default value, which is used wherever the parameter controller is not used to change the parameter.
Selecting All
means that the parameter can be any value of the selected type. For example, if the parameter type is number, then the parameter value can be any number.
Selecting List
requires providing a selectable list for the parameter. The list can be entered manually or obtained from a field.
As shown, click Add from Field
, select a dataset from the current application, list the fields in the dataset that match the parameter type, click to select a field, and the field values will fill the list.
Clicking Clear All
will empty the list.
When the parameter type is number
or date
, there is a range
option for parameter value.
When selecting a number type, you need to set the maximum
, minimum
, and step
, with a default step
of 1.
When choosing a date type, you need to set the start and end time
, step
, and step cycle: year, quarter, month, week, day.
Display Value
is the value shown to the user. In the parameter controller, the selected value is the display value, but the backend actually uses the value
.
Click on the three-dot menu in the parameter list, select Edit Parameter
from the pop-up menu to open the edit parameter dialog and make changes to the parameter.
When editing a parameter name, any places where the parameter is used in expressions will give an error: parameter xxx does not exist.
When editing the parameter type, the places using the parameter will also give an error.
Changes to the parameter's selectable values without modifying the parameter name and type will not cause an error.
Click on the three-dot menu in the parameter list, and choose Delete
from the pop-up menu to delete the parameter.
The parameter controller is used to control the current value of the parameter. It can be part of the dashboard layout, like a filter, and can control the display of charts by adjusting parameter values.
Click the Add Parameter Controller
icon in the dashboard to add a parameter controller to the dashboard.
Select a parameter from the Parameter
list on the left and drag it into the parameter configuration area, and a filter in the form of a parameter will appear in the dashboard. Parameters can only be selected one at a time because a parameter can only have one current value.
Switch to the Style
tab to set various styles for the parameter controller. The settings differ for different types of parameters: text, number, date, time. For detailed settings, see the style settings of the layout filter.
When using parameters in SQL queries or table names, uniformly use {{%%parameter_name}}
, the backend only does text replacement, regardless of the type.
When creating a data set, for Simple Filter
, the way to use parameters is as follows:
In Expression Filter
, you can use either the parameter {{%parameter_name}}
or the parameter value {{%%parameter_name}}
, in addition, fields need to be enclosed in {}.
In the image below, the default value of the parameter "version" is 3.2. After filtering with the expression {milestone} = {{%version}}
, the result will only show rows where milestone equals 3.2:
In the expression for adding fields and metrics, you can use either the parameter {{%parameter_name}}
or the parameter value {{%%parameter_name}}
.
Using Parameter: {{%parameter_name}}
Using Parameter Value: {{%%parameter_name}}
The way of using parameters in chart filters is the same as adding fields/metrics: