KeyColorColorizer Class

A colorizer that allows choosing the color depending on the SeriesBase.ColorDataMember values used as key values.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.dll


public class KeyColorColorizer :
Public Class KeyColorColorizer
    Inherits ChartPaletteColorizerBase
    Implements IPatternHolder


This class introduces the KeyColorColorizer.Keys property that allows specifying keys associated with colors, and the KeyColorColorizer.KeyProvider property, that allows specifying how to obtain the key for SeriesBase.ColorDataMember values.

Use the SeriesViewBase.Colorizer property to assign the colorizer to a series view.

Refer to the Series Point Colorizer topic for more information about colorizers.


To configure and use the Key-Color colorizer, perform the following steps.

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Linq;
using DevExpress.XtraCharts;

namespace KeyColorColorizerExample {
    public partial class Form1 : Form {
        const string filepath = "..//..//Data//GDP.xml";

        public Form1() {

        private void Form1_Load(object sender, EventArgs e) {
            #region #BarSeries
            // Create and customize a bar series.
            Series barSeries = new Series() {
                DataSource = LoadData(filepath),
                ArgumentDataMember = "Country",
                ColorDataMember = "Region",
                View = new SideBySideBarSeriesView()
            barSeries.View.Colorizer = CreateColorizer();
            barSeries.ValueDataMembers.AddRange(new string[] { "Product" });
            #endregion #BarSeries

            // Add the series to the ChartControl's Series collection.

            // Show a title for the values axis.
            ((XYDiagram)chartControl1.Diagram).AxisY.Title.Text = "GDP per capita, $";
            ((XYDiagram)chartControl1.Diagram).AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;

        #region #KeyColorColorier
        // Creates the Key-Color colorizer for the bar chart.
        ChartColorizerBase CreateColorizer() {
            KeyColorColorizer colorizer = new KeyColorColorizer() {
                PaletteName = "Apex"

            return colorizer;
        #endregion #KeyColorColorier

        #region #DataLoad
        class HpiPoint {
            public string Country { get; set; }
            public double Product { get; set; }
            public string Region { get; set; }

        // Loads data from an XML data source.
        static List<HpiPoint> LoadData(string filepath) {
            XDocument doc = XDocument.Load(filepath);
            List<HpiPoint> points = new List<HpiPoint>();
            foreach (XElement element in doc.Element("G20HPIs").Elements("CountryStatistics")) {
                points.Add(new HpiPoint() {
                    Country = element.Element("Country").Value,
                    Product = Convert.ToDouble(element.Element("Product").Value),
                    Region = element.Element("Region").Value
            return points;
        #endregion #DataLoad
See Also