Bind the grouping to allow the dashboard viewer to select which dimensions to group the results by. For example, you can show different groupings in a chart based on the selection in a toggle widget.
To dynamically set the grouping in a query based on a selection, bind the
groups property in the query. If the query is used for a chart, also bind the corresponding widget property under
columnMap to identify the chart attribute by the selected grouping. Some charts accept multiple groupings and use them differently. For example, the stacked bar chart can have two groupings, one for the vertical axis and one used to segment the bars. The
columnMap widget-level property has subproperties that specify which grouping to use for each of these chart attributes.
To dynamically set the grouping in a query based on a selection, complete these tasks.
- Bind the
groupsproperty of the query.
- If the query is used for a chart, replace the
columnMapsection of the widget with an empty
columnsarray. Why? Because when you change the query, the set of fields can be different from what’s in the
columnMapsection. When you replace the
columnMapproperty with an empty
columnsarray, the system remaps the columns based on the new query definition.
For example, let’s bind the grouping for this donut chart based on the selection in the toggle widget.
Dashboard selections automatically reset each time you change your query grouping. For example, if you drill into Air Up and then switch your grouping to Country, the donut chart resets and Air Up is no longer selected.
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 (
value) that determines the grouping.
Let’s bind the
value field of the custom query (
GroupingsController_1) to the grouping in the donut chart’s query (
PieByProduct_2). Any selection in the custom query passes the grouping to the
When you create the donut chart, by default, the widget (
chart_3) 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