dashboard-15333-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-dashboard-item-settings-pies-providing-data.md
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 Pie dashboard item to data in the Designer or in code.
The image below shows a sample Pie dashboard item that is bound to data.
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
|
Note
In case of negative measure values, Pie uses their absolute values.
|
Contains data items that define the share of pie segments.
| |
Arguments
|
|
Contains data items that provide values used to label pie segments.
| |
Series
|
|
Contains data items whose values are used to label pie charts.
|
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.
To transpose the selected Pie dashboard item, use the Transpose button in the Home ribbon tab.
To provide data for the Pie dashboard item, use the following properties.
|
Arguments
|
ChartDashboardItemBase.Arguments
| |
Series
|
SeriesDashboardItem.SeriesDimensions
| |
Values
|
|
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() {
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();
}
}
}
Imports DevExpress.DashboardCommon
Imports System
Imports System.Windows.Forms
Namespace Dashboard_CreatePies
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Function CreatePies(ByVal dataSource As IDashboardDataSource) As PieDashboardItem
Dim pies As 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
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim excelDataSource As New DashboardExcelDataSource()
excelDataSource.FileName = "SalesPerson.xlsx"
Dim options As New DevExpress.DataAccess.Excel.ExcelSourceOptions()
Dim importSettings = New DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
importSettings.WorksheetName = "Data"
importSettings.CellRange = "A1:L100"
options.ImportSettings = importSettings
excelDataSource.SourceOptions = options
excelDataSource.Fill()
Dim dashBoard As New Dashboard()
dashBoard.DataSources.Add(excelDataSource)
Dim pies As PieDashboardItem = CreatePies(excelDataSource)
dashBoard.Items.Add(pies)
dashboardViewer1.Dashboard = dashBoard
dashboardViewer1.ReloadData()
End Sub
End Class
End Namespace