Measure Interactions
Bind the measure to allow the dashboard viewer to select which measures to show in a widget. For example, you can show different measures in a chart based on the selection in a toggle widget.
To dynamically set the measure in a query based on a selection, complete these tasks.
- Bind the
measures
property of the query. - If the query is used for a chart, replace the
columnMap
section of the widget with an emptycolumns
array. Why? Because when you change the query, the set of fields is different from what’s in thecolumnMap
section. When you replace thecolumnMap
property with an emptycolumns
array, the system remaps the columns based on the new query definition. - Binding isn’t allowed using the
columnMap
property.
Let’s look at an example where we bind the measure for a donut chart based on the selection in the toggle widget.
The toggle widget uses this custom query.
Each toggle option has one display label (display
) that appears in the toggle. It also has one value (step_property
) that determines the measure.
Let’s bind the step_property
field of the custom query (MeasuresController_1
) to the measure in the donut chart’s step (PieByProduct_2
). Any selection in the custom query passes the aggregation method (like sum or count) and the measure field to the PieByProduct_2
query.
When you create the donut chart, by default, the widget (chart_2
) contains the columnMap
section that maps measures and groupings to chart attributes.
The properties under the columnMap
property vary based on the chart type.
For the interaction to work correctly, replace the columnMap
section with an empty columns
array because interactions can’t be used to specify columnMap
.