Skip to main content

Providing Data

  • 3 minutes to read

The Dashboard Designer allows you to bind dashboard items to data in a uniform and similar manner. See the Bind Dashboard Items to Data topic for common information.

The difference is in the data sections that the specific dashboard item has. This topic describes how to bind the Pivot dashboard item to data in the Designer or in code.

Binding to Data in the Designer

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

PivotProvidingData_Main

To bind the Pivot 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 a Pivot’s data sections.

Section Processed as Description
Values Measure Contains data items used to calculate values displayed in the pivot table.
Columns Dimension Contains data items whose values are used to label columns.
Rows Dimension Contains data items whose values are used to label rows.

Transposing Columns and Rows

The Pivot dashboard item provides the capability to transpose pivot columns and rows. In this case, data items contained in the Columns section are moved to the Rows section and vice versa.

Pivot_Transpose

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

TransposeButton_Ribbon

Binding to Data in Code

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

Values

PivotDashboardItem.Values

Columns

PivotDashboardItem.Columns

Rows

PivotDashboardItem.Rows

Example

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

View Example

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

namespace Dashboard_CreatePivot {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private PivotDashboardItem CreatePivot(IDashboardDataSource dataSource) {
            PivotDashboardItem pivot = new PivotDashboardItem();
            pivot.DataSource = dataSource;
            pivot.Columns.AddRange(new Dimension("Country"), new Dimension("Sales Person"));
            pivot.Rows.AddRange(new Dimension("CategoryName"), new Dimension("ProductName"));
            pivot.Values.AddRange(new Measure("Extended Price"), new Measure("Quantity"));
            pivot.AutoExpandColumnGroups = false;
            pivot.AutoExpandRowGroups = true;
            return pivot;
        }
        private void Form1_Load(object sender, EventArgs e) {

            Dashboard dashboard = new Dashboard();
            DashboardExcelDataSource dataSource = new DashboardExcelDataSource()
            {
                FileName = "SalesPerson.xlsx",
                SourceOptions = new DevExpress.DataAccess.Excel.ExcelSourceOptions(
                    new DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
                    {
                        WorksheetName = "Data",
                        CellRange = "A1:L100"
                    }
                    )
            };
            dataSource.Fill();
            dashboard.DataSources.Add(dataSource);

            PivotDashboardItem pivot = CreatePivot(dataSource);
            dashboard.Items.Add(pivot);

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