Example T830478
Visible to All Users

Dashboard for WinForms - How to Display the Others Slice in the Pie Chart

This example demonstrates the Pie Chart that displays slices for data rows selected in the Grid, while unselected data comprises the Others slice.

screenshot

The dashboard is designed as follows:

  • 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 to filter data.
  • 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 MasterFilterSet event occurs. The code in the event handler obtains filter values and assigns them to the dashboard parameters.
When the user executes the Clear Master Filter command, the MasterFilterCleared event occurs. The event is handled to clear parameters by assigning null to the parameter's SelectedValues.

Another approach to perform the same task involves a custom visual interactivity instead of Master Filtering. Review the Custom Visual Interactivity to Display the Others Slice in the Pie Chart example for more information.

Files to Review

Form1.cs / Form1.vb

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

PieChartOtherSliceExample/Form1.cs(vb)
C#
using DevExpress.DashboardCommon; using DevExpress.DashboardWin; using DevExpress.XtraEditors; using System.IO; using System.Linq; namespace PieChartOtherSliceExample { public partial class Form1 : XtraForm { public Form1() { InitializeComponent(); dashboardViewer1.ConfigureDataConnection += dashboardViewer1_ConfigureDataConnection; dashboardViewer1.MasterFilterSet += dashboardViewer1_MasterFilterSet; dashboardViewer1.MasterFilterCleared += DashboardViewer1_MasterFilterCleared; dashboardViewer1.LoadDashboard("Dashboard.xml"); } private void dashboardViewer1_MasterFilterSet(object sender, MasterFilterSetEventArgs e) { DashboardViewer viewer = (DashboardViewer)sender; if (e.DashboardItemName == "gridDashboardItem1") { var stringValues = e.SelectedValues.Select(value => value[1].ToString()); viewer.Parameters["ParamSalesPerson"].SelectedValues = stringValues; } if(e.DashboardItemName == "rangeFilterDashboardItem1") { viewer.Parameters["ParamRangeStart"].SelectedValue = e.SelectedRange.Minimum; viewer.Parameters["ParamRangeEnd"].SelectedValue = e.SelectedRange.Maximum; } } private void DashboardViewer1_MasterFilterCleared(object sender, MasterFilterClearedEventArgs e) { DashboardViewer viewer = (DashboardViewer)sender; foreach (var p in viewer.Parameters.ToList()) p.SelectedValues = null; ; } private void dashboardViewer1_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e) { ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters; if (parameters != null) parameters.FileName = Path.GetFileName(parameters.FileName); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.