Back to Devexpress

MapPieMappingInfo Class

windowsforms-devexpress-dot-xtramap-1d1b77a2.md

latest6.0 KB
Original Source

MapPieMappingInfo Class

Contains information about mapping the Pie chart item.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public class MapPieMappingInfo :
    MapChartItemMappingInfo
vb
Public Class MapPieMappingInfo
    Inherits MapChartItemMappingInfo

The following members return MapPieMappingInfo objects:

Remarks

An object of this class can be accessed using the PieChartDataAdapter.Mappings property.

Example

The PieChartDataAdapter class is intended to automatically generate pie charts from a data source.

  1. Create the PieChartDataAdapter object, set its DataSourceAdapterBase.DataSource property and assign this data adapter to the VectorItemsLayer.Data property.

  2. Specify the following PieChartDataAdapter properties:

  3. Initialize the VectorItemsLayer.Colorizer property with a KeyColorColorizer object.

csharp
public Form1() {
    InitializeComponent();

    // Assign a PieChartDataAdapter object to Data.
    PieLayer.Data = CreateData();

    // Assign a KeyColorColorizer object to Colorizer.
    PieLayer.Colorizer = CreateColorizer();
}
// Create a pie chart data adapter and specify its parameters.   
IMapDataAdapter CreateData() {
    PieChartDataAdapter adapter = new PieChartDataAdapter() {
        DataSource = LoadDataFromXml(xmlFilepath),
        PieItemDataMember = "Name",
        ItemMinSize = 20,
        ItemMaxSize = 60
    };

    // Specify mappings.
    adapter.Mappings.Latitude = "CapitalLat";
    adapter.Mappings.Longitude = "CapitalLon";
    adapter.Mappings.PieSegment = "MedalClass";
    adapter.Mappings.Value = "Quantity";

    // Specify measure rules.
    adapter.MeasureRules = new MeasureRules();
    adapter.MeasureRules.RangeStops.Add(1);
    adapter.MeasureRules.RangeStops.Add(10);
    adapter.MeasureRules.RangeStops.Add(20);
    adapter.MeasureRules.RangeStops.Add(30);
    adapter.MeasureRules.RangeStops.Add(40);

    return adapter;
}
private DataTable LoadDataFromXml(string path) {
    DataSet ds = new DataSet();
    ds.ReadXml(path);
    DataTable table = ds.Tables[0];
    return table;
}
// Create a colirizer and specify its options.
MapColorizer CreateColorizer() {
    KeyColorColorizer colorizer = new KeyColorColorizer() {
        ItemKeyProvider = new ArgumentItemKeyProvider()
    };

    colorizer.Colors.Add(Color.FromArgb(255, 207, 98));
    colorizer.Colors.Add(Color.FromArgb(169, 181, 188));
    colorizer.Colors.Add(Color.FromArgb(233, 152, 118));

    colorizer.Keys.Add(new ColorizerKeyItem() { Key = 1, Name = "Gold" });
    colorizer.Keys.Add(new ColorizerKeyItem() { Key = 2, Name = "Silver" });
    colorizer.Keys.Add(new ColorizerKeyItem() { Key = 3, Name = "Bronze" });

    return colorizer;
}
vb
Public Sub New()
    InitializeComponent()

    ' Assign a PieChartDataAdapter object to Data.
    PieLayer.Data = CreateData()

    ' Assign a KeyColorColorizer object to Colorizer.
    PieLayer.Colorizer = CreateColorizer()
End Sub

' Create a pie chart data adapter and specify its parameters.  
Private Function CreateData() As IMapDataAdapter
    Dim adapter As New PieChartDataAdapter() With {.DataSource = LoadDataFromXml(xmlFilepath), .PieItemDataMember = "Name", .ItemMinSize = 20

    ' Specify mappings.
    adapter.Mappings.Latitude = "CapitalLat"
    adapter.Mappings.Longitude = "CapitalLon"
    adapter.Mappings.PieSegment = "MedalClass"
    adapter.Mappings.Value = "Quantity"

    ' Specify measure rules.
    adapter.MeasureRules = New MeasureRules()
    adapter.MeasureRules.RangeStops.Add(1)
    adapter.MeasureRules.RangeStops.Add(10)
    adapter.MeasureRules.RangeStops.Add(20)
    adapter.MeasureRules.RangeStops.Add(30)
    adapter.MeasureRules.RangeStops.Add(40)

    Return adapter
End Function

Private Function LoadDataFromXml(ByVal path As String) As DataTable
    Dim ds As New DataSet()
    ds.ReadXml(path)
    Dim table As DataTable = ds.Tables(0)
    Return table
End Function

' Create a colirizer and specify its options.
Private Function CreateColorizer() As MapColorizer
    Dim colorizer As New KeyColorColorizer() With {.ItemKeyProvider = New ArgumentItemKeyProvider()}

    colorizer.Colors.Add(Color.FromArgb(255, 207, 98))
    colorizer.Colors.Add(Color.FromArgb(169, 181, 188))
    colorizer.Colors.Add(Color.FromArgb(233, 152, 118))

    colorizer.Keys.Add(New ColorizerKeyItem() With {.Key = 1, .Name = "Gold"})
    colorizer.Keys.Add(New ColorizerKeyItem() With {.Key = 2, .Name = "Silver"})
    colorizer.Keys.Add(New ColorizerKeyItem() With {.Key = 3, .Name = "Bronze"})

    Return colorizer
End Function

Inheritance

Object MapItemMappingInfoBase MapItemMappingInfo MapChartItemMappingInfo MapPieMappingInfo

See Also

MapPieMappingInfo Members

DevExpress.XtraMap Namespace