Skip to main content

ChoroplethColorizer.ValueProvider Property

Provides values from the data source (Shapefile or KML file) to color map shapes according to data.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v24.1.dll

NuGet Package: DevExpress.Win.Map

Declaration

[DefaultValue(null)]
public IColorizerValueProvider ValueProvider { get; set; }

Property Value

Type Default Description
IColorizerValueProvider null

An object that implements the IColorizerValueProvider interface.

Remarks

Refer Colorizers for more information about colorizers the Map Control provides.

Example

This example demonstrates how to paint each map contour in a specific color. To accomplish this, it is necessary to create a colorizer (choropleth or graph) and assign it to the VectorItemsLayer.Colorizer property.

For this colorizer, it is necessary to create a ShapeAttributeValueProvider object, specify the name of the shape attribute that contains a value to be colorized to its ShapeAttributeValueProvider.AttributeName property, and assign this value provider to the ChoroplethColorizer.ValueProvider property.

Then, split the entire data into ranges and add the required range stops to the DoubleCollection returned by the ChoroplethColorizer.RangeStops property.

Finally, add the desired set of colors to the GenericColorizerItemCollection<T> that is accessed from the ChoroplethColorizer.ColorItems property. The colorizer automatically associates each color with the specified data ranges.

Note

  • If you wish to display information on what each color means, create a Color Scale legend. To do this, create a ColorScaleLegend object and add it to the MapControl.Legends collection. In this legend, set its ItemsLayerLegend.Layer property to the previously created layer object and adjust other legend properties as required.
  • If you wish copy the shape file to your project, you should also copy the Countries.dbf file.

View Example

    // Create colorizer for the MapLayer.
    MapLayer.Colorizer = CreateColorizer();
private MapColorizer CreateColorizer() {
    // Create a Choropleth colorizer
    ChoroplethColorizer colorizer = new ChoroplethColorizer();

    // Specify colors for the colorizer.
    colorizer.ColorItems.AddRange(new ColorizerColorItem[] {
        new ColorizerColorItem(Color.FromArgb(0x5F, 0x8B, 0x95)), 
        new ColorizerColorItem(Color.FromArgb(0x79, 0x96, 0x89)),
        new ColorizerColorItem(Color.FromArgb(0xA2, 0xA8, 0x75)), 
        new ColorizerColorItem(Color.FromArgb(0xCE, 0xBB, 0x5F)),
        new ColorizerColorItem(Color.FromArgb(0xF2, 0xCB, 0x4E)),
        new ColorizerColorItem(Color.FromArgb(0xF1, 0xC1, 0x49)), 
        new ColorizerColorItem(Color.FromArgb(0xE5, 0xA8, 0x4D)),
        new ColorizerColorItem(Color.FromArgb(0xD6, 0x86, 0x4E)),
        new ColorizerColorItem(Color.FromArgb(0xC5, 0x64, 0x50)), 
        new ColorizerColorItem(Color.FromArgb(0xBA, 0x4D, 0x51))
    });

    // Specify range stops for the colorizer.
    colorizer.RangeStops.AddRange(new double[] { 0, 3000, 10000, 18000, 28000, 
        44000, 82000, 185000, 1000000, 2500000, 15000000 });

    // Specify the attribute that provides data values for the colorizer.
    colorizer.ValueProvider = new ShapeAttributeValueProvider() { AttributeName = "GDP_MD_EST" };

    return colorizer;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ValueProvider property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also