The requested page is not available for the requested platform. You are viewing the content for Default platform.

Providing Data

  • 3 min to read

The Dashboard Designer allows you to bind various dashboard items to data in a virtually uniform manner. To learn more, see the Binding Dashboard Items to Data topic.

The only difference is in the data sections that the required dashboard item has. This topic describes how to bind a Pie dashboard item to data in the Designer or in code.

Binding to Data in the Designer

The image below shows a sample Pie dashboard item that is bound to data.

PiesProvidingData_Main

To bind the Pie dashboard item to data, drag and drop a data source field to a placeholder contained in one of the available data sections. A table below lists and describes Pie's data sections.

Section

Processed as

Description

Values

Measure

Note

In case of negative measure values, Pie uses their absolute values.

Contains data items that define the share of pie segments.

Arguments

Dimension

Contains data items that provide values used to label pie segments.

Series

Dimension

Contains data items whose values are used to label pie charts.

Transposing Arguments and Series

The Pie dashboard item provides the capability to transpose pie arguments and series. In this case, data items contained in the Arguments section are moved to the Series section, and vice versa.

Pies_Transpose

To transpose the selected Pie dashboard item, use the Transpose button in the Home ribbon tab.

TransposeButton_Ribbon

Binding to Data in Code

To provide data for the Pie dashboard item, use the following properties.

Arguments

ChartDashboardItemBase.Arguments

Series

SeriesDashboardItem.SeriesDimensions

Values

PieDashboardItem.Values

Example

The following example demonstrates how to bind a Pie dashboard item to data in code.

Note

The complete sample project How to Bind a Pie Dashboard Item to Data at Runtime is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using System;
using System.Windows.Forms;

namespace Dashboard_CreatePies
{
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private PieDashboardItem CreatePies(IDashboardDataSource dataSource) {
            PieDashboardItem pies = new PieDashboardItem();
            pies.DataSource = dataSource;
            pies.Values.Add(new Measure("Extended Price"));
            pies.Arguments.Add(new Dimension("Country"));
            pies.SeriesDimensions.Add(new Dimension("OrderDate"));
            return pies;
        }
        private void Form1_Load(object sender, EventArgs e) {
           DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource()
            {
                FileName = "SalesPerson.xlsx",
                SourceOptions = new DevExpress.DataAccess.Excel.ExcelSourceOptions(
                    new DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
                    {
                        WorksheetName = "Data",
                        CellRange = "A1:L100"
                    }
                )
            };
            excelDataSource.Fill();

            Dashboard dashBoard = new Dashboard();
            dashBoard.DataSources.Add(excelDataSource);
            PieDashboardItem pies = CreatePies(excelDataSource);
            dashBoard.Items.Add(pies);

            dashboardViewer1.Dashboard = dashBoard;
            dashboardViewer1.ReloadData();
        }
    }
}