How to Display the Others Slice in the Pie Chart

  • 3 min to read

This example demonstrates a Pie Chart that displays slices for data rows selected in the Grid, while unselected data comprises the Others slice. Two approaches for creating the Others slice are detailed below.

Master Filtering and Parameters

screenshot

The dashboard design is based on the following key points:

  • The Pie Chart does not take part in master filtering. It has the Ignore Master Filter option enabled. The Pie Chart gets data from the calculated fields whose expressions include dashboard parameters. The dashboard parameter values filters the data displayed in the pie chart.

  • The dashboard's hidden ParamSalesPerson parameter is a list of Sales Person names. The hidden ParamRangeStart and ParamRangeEnd parameters contains the start and end values selected in the Range Filter.

  • The calculated field OthersChartSalesPerson provides data for the chart's Argument and contains the following expression: Iif(?ParamSalesPerson Is Null, [Sales Person], Iif([Sales Person] In (?ParamSalesPerson), [Sales Person], 'Others'))

  • The calculated field ChartRangeExtPrice provides data for the chart's Value and contains the following expression: Iif(?ParamRangeStart Is Null, [Extended Price], Iif([OrderDate] Between(?ParamRangeStart, ?ParamRangeEnd), [Extended Price], 0))

When a user selects a row in the Grid, the DashboardViewer.MasterFilterSet event occurs. The code in the event handler obtains filter values and assigns them to the dashboard's parameters.

Note

The complete sample project How to Display the Others Slice in the Pie Chart is available in the DevExpress Examples repository.

Custom Visual Interactivity and Parameters

screenshot

This section illustrates another approach to display the "Others" pie in the pie chart. The dashboard in the picture above is designed as follows:

  • The Grid does not act as master filter item.

  • The Pie Chart Argument data is bound to the calculated field whose expression include dashboard parameter.

  • The dashboard's hidden ParamSalesPerson parameter is a list of Sales Person names.

  • The calculated field OthersChartSalesPerson provides data for the chart's Argument and contains the following expression: Iif(?ParamSalesPerson Is Null, [Sales Person], Iif([Sales Person] In (?ParamSalesPerson), [Sales Person], 'Others'))

When the Dashboard Viewer loads the dashboard, the DashboardViewer.DashboardItemVisualInteractivity event occurs. The code in the event handler specifies the selection mode.

When a user selects a row in the Grid, the DashboardViewer.DashboardItemSelectionChanged event occurs. The code in the event handler obtains filter values, assigns them to the dashboard parameters and stores the selection in the local variable.

Dashboard parameter values modification fires the DashboardViewer.DashboardItemVisualInteractivity event. The saved selection state is used to restore the selected rows in the Grid.

Note

The complete sample project Custom Visual Interactivity to Display the Others Slice in the Pie Chart is available in the DevExpress Examples repository.