Colorizer
- 3 minutes to read
This document introduces the Chart Colorizer, lists colorizer types, and explains how to create a colorizer and customize its settings in a chart control.
The document consists of the following sections.
Overview
The Colorizer is used to automatically choose colors for chart series points. This feature can be applied to the SeriesPoint class. The calculated color is stored using the SeriesPoint.Color property.
This can be useful for providing additional information using color.
Before using this feature, perform the following steps.
Specify the Series.DataSource property and all data member properties required to build a chart.
The colorizer allows you to provide colors for the series points provided from the data source using one of approaches that will be discussed later.
Specify the name of a data member that determines the color of the series’ SeriesBase.ColorDataMember property.
Determine which kind of a colorizer should be used in an application.
Currently, the following types are supported.
- ColorObjectColorizer allows you to provide color data member values to the SeriesPoint.Color property if these values have the Color type or a type that can be converted to a color (integer number or string).
- KeyColorColorizer allows you to choose the color depending on color data member values used as key values.
- RangeColorizer allows you to colorize points depending on the range that color data member values belong to.
After you select a colorizer type, assign an object of the selected colorizer type to the SeriesBase.Colorizer property. Then, you can customize the colorizer’s settings. The sections below describe how this can be done.
Color Object Colorizer
This colorizer does not have properties that should be specified before you use this colorizer. The following image demonstrates the data colorized using one of the national colors stored in a data source.
Note
This colorizer is used by default.
Key-Color Colorizer
To configure the key-color colorizer, perform the following steps.
Fill the KeyColorColorizer.Keys collection.
Specify the ChartPaletteColorizerBase.Palette property if you want to use a non-default palette to colorize your data.
In addition, it’s possible to specify the KeyColorColorizer.KeyProvider property to change the way you provided keys based on the color data source member.
Note
This property can be changed only in code.
The following image demonstrates a bar chart colorized by the country’s region using the key-color colorizer.
Range Colorizer
To configure the range colorizer, perform the following steps.
Fill the RangeColorizer.RangeStops collection. These values will form ranges that will be used to decide which color a series point should have.
Specify the ChartPaletteColorizerBase.Palette property if you want use a non-default palette to colorize your data.
In addition, it’s possible to specify the RangeColorizer.ValueProvider property. This allows you to configure double-precision numeric values are provided, based on the color data series member values.
Note
This property can be changed only in code.
The following image demonstrates a bar chart colorized by the Happy Planet Index using the range colorizer.