How to: Bind a Pie Dashboard Item to Data in Code

  • 2 minutes to read

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

View Example: How to Bind a Pie Dashboard Item to Data at Runtime

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

namespace Dashboard_CreatePies
    public partial class Form1 : Form {
        public Form1() {
        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"

            Dashboard dashBoard = new Dashboard();
            PieDashboardItem pies = CreatePies(excelDataSource);

            dashboardViewer1.Dashboard = dashBoard;
See Also