dashboard-16472-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-dashboard-item-settings-choropleth-map-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 Choropleth Map dashboard item to data in the Designer or in code.
The image below shows a sample Choropleth Map dashboard item that is bound to data.
To bind the Choropleth Map dashboard item to data, drag and drop a data source field to a placeholder contained in one of the available data sections. The Choropleth Map provides two data item groups for data binding: DATA ITEMS and TOOLTIP DATA ITEMS. Tables below list the available data sections.
|
Section
|
Processed as
|
Description
| | --- | --- | --- | |
Attribute
|
|
Allows you to associate map shapes with data source field values.
To associate map shapes with data source field values, drag-and-drop the required dimension to the data item’s placeholder and select the required attribute in the Map Attribute Binding dialog. To invoke this dialog, click the Options button (the icon) next to the Attribute placeholder.
Select the required attribute and click OK.
| |
Maps
|
|
Contains data items whose values are used to color map shapes. Map shape colors vary based on the map type.
Click the Options button (the or icon depending on the map type) next to the Value placeholder and select the required map type in the invoked Choropleth Map Options dialog.
Note
You can fill several data item containers in the Maps section and use the Values drop-down menu to switch between the provided values. To invoke the Values menu, click the icon in the dashboard item caption.
|
|
Section
|
Processed as
|
Description
| | --- | --- | --- | |
Measures
|
|
Allows you to add supplementary content to the tooltips. Drag and drop the required measures to provide additional data.
|
To provide data for the Choropleth Map dashboard item, do the following.
Provide the required map. Use the MapDashboardItem.Area property to specify the built-in map or specify the existing shapefile using the MapDashboardItem.CustomShapefile property.
Specify the binding between the required map attribute and the data source field. Use the ChoroplethMapDashboardItem.AttributeName property to specify the name of the required attribute. Specify the corresponding dimension using the ChoroplethMapDashboardItem.AttributeDimension property.
Specify the measure or set of measures that will be used to color map shapes.
Optionally, provide tooltip values using the MapDashboardItem.TooltipMeasures property.
The following code snippet demonstrates how to bind a Choropleth Map dashboard item to data in code.
using System.Windows.Forms;
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
namespace Dashboard_CreateChoroplethMap {
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1() {
InitializeComponent();
Dashboard dashboard = new Dashboard();
DashboardSqlDataSource dataSource = new DashboardSqlDataSource();
CustomSqlQuery sqlQuery = new CustomSqlQuery("Countries", "select * from Countries");
dataSource.ConnectionParameters = new Access97ConnectionParameters(@"..\..\Data\countriesDB.mdb", "", "");
dataSource.Queries.Add(sqlQuery);
ChoroplethMapDashboardItem choroplethMap = new ChoroplethMapDashboardItem();
choroplethMap.DataSource = dataSource;
choroplethMap.DataMember = "Countries";
choroplethMap.Area = ShapefileArea.WorldCountries;
choroplethMap.AttributeName = "NAME";
choroplethMap.AttributeDimension = new Dimension("Country");
ValueMap populationMap = new ValueMap(new Measure("Population"));
choroplethMap.Maps.Add(populationMap);
dashboard.Items.Add(choroplethMap);
dashboardViewer1.Dashboard = dashboard;
}
}
}
Imports System.Windows.Forms
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
Namespace Dashboard_CreateChoroplethMap
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
Dim dashboard As New Dashboard()
Dim dataSource As New DashboardSqlDataSource()
Dim sqlQuery As New CustomSqlQuery("Countries", "select * from Countries")
dataSource.ConnectionParameters = New Access97ConnectionParameters("..\..\Data\countriesDB.mdb", "", "")
dataSource.Queries.Add(sqlQuery)
Dim choroplethMap As New ChoroplethMapDashboardItem()
choroplethMap.DataSource = dataSource
choroplethMap.DataMember = "Countries"
choroplethMap.Area = ShapefileArea.WorldCountries
choroplethMap.AttributeName = "NAME"
choroplethMap.AttributeDimension = New Dimension("Country")
Dim populationMap As New ValueMap(New Measure("Population"))
choroplethMap.Maps.Add(populationMap)
dashboard.Items.Add(choroplethMap)
dashboardViewer1.Dashboard = dashboard
End Sub
End Class
End Namespace
See Also