ChoroplethColorizer Class
Represents the Choropleth-like colorizer.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.1.dll
NuGet Package: DevExpress.Win.Map
Declaration
public class ChoroplethColorizer :
GenericColorizer<ColorizerColorItem>,
ILegendDataProvider,
IChoroplethColorizer,
IColorizer
Related API Members
The following members return ChoroplethColorizer objects:
Remarks
The ChoroplethColorizer class is intended to colorize vector items based on their values.
To colorize vector items using this colorizer, assign an instance of the ChoroplethColorizer class to the VectorItemsLayer.Colorizer property and adjust its settings as required. For instance, specify colors via the ChoroplethColorizer.ColorItems property, range intervals via the ChoroplethColorizer.RangeStops property and the manner of distributing colors along range intervals via the ChoroplethColorizer.RangeDistribution property.
For more information, refer to Colorizers.
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.
// 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;
}