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

  • 2 minutes to read

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

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

uusing System;
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraEditors;

namespace Dashboard_CreatePieMap {
    public partial class Form1 : XtraForm {
        public Form1() {

        private void Form1_Load(object sender, EventArgs e)
            Dashboard dashboard = new Dashboard();

            DashboardSqlDataSource xmlDataSource = new DashboardSqlDataSource();
            xmlDataSource.ConnectionParameters =
                new XmlFileConnectionParameters(@"..\..\Data\DashboardEnergyStatictics.xml");
            SelectQuery sqlQuery = SelectQueryFluentBuilder
                .SelectColumns("Latitude", "Longitude", "Production", "EnergyType", "Country")
                .Build("Query 1");

            PieMapDashboardItem pieMap = CreatePieMap(xmlDataSource);

            dashboardViewer1.Dashboard = dashboard;

        private static PieMapDashboardItem CreatePieMap(DashboardSqlDataSource xmlDataSource)
            PieMapDashboardItem pieMap = new PieMapDashboardItem();
            pieMap.DataSource = xmlDataSource;
            pieMap.DataMember = "Query 1";

            pieMap.Area = ShapefileArea.Europe;

            pieMap.Latitude = new Dimension("Latitude");
            pieMap.Longitude = new Dimension("Longitude");

            pieMap.Values.Add(new Measure("Production"));
            pieMap.Argument = new Dimension("EnergyType");

            pieMap.TooltipDimensions.Add(new Dimension("Country"));
            pieMap.Legend.Visible = true;
            return pieMap;
See Also