In This Topic
Fill rules are used to colorize a map based on the values of a shape field. When creating a fill rule you must specify the shapefile it is used on, the fill rule data column name and the colors to use (all of them or only the first, the last and their count). There are two types of fill rules:
- Value fill rules - all unique values in the fill rule's data column are extracted and each unique value is colorized with the respective color. If the unique values are more than the colors, then the color counting is restarted and some different values will have the same color.
- Range fill rules - these fill rules are only applicable to data columns containing numbers. All unique values in the fill rule's data column are extracted and then are grouped in a specified number of classes using the grouping algorithm specified for the DataGrouping property. You can specify whether the data ranges calculated by the data grouping algorithm should be rounded using the RoundedRanges property. If needed you can even create your own data grouping algorithm by extending the NDataGrouping class. The following code demonstrates how to create and add fill rules to the FillRules collection of the map importer:
Adding fill rule |
Copy Code
|
NMapFillRuleRange fillRule = new NMapFillRuleRange(countries, "POP_CNTRY", Color.White, Color.Black, 12);
fillRule.DataGrouping = new NDataGroupingOptimal();
shapefile.FillRule = fillRule;
|
The following images illustrate the different data grouping algorithms applied to a world map, which contains information about the population of each country:
-
Optimal - adjusts the size of data intervals in order to minimize the classification error and thus the map looks more balanced and the results seem more correct, with just a few shapes in the highest class as one would expect. This is the default data grouping algorithm for range fill rules.
-
Equal Distribution - also known as quantiles, this method allows for unequally sized data intervals and involves adjustment of the interval limits until an equal number of data points can be slotted into each interval.
-
Equal Interval - also known as equal ranges (or steps), this method involves division of the entire data range into equally sized intervals.
See Also