Skip to main content

SeriesColorizerBase.GetSeriesColor(Object, Palette) Method

Returns a color by the specified series identifier.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.2.dll

Declaration

public abstract Color GetSeriesColor(
    object seriesKey,
    Palette palette
)

Parameters

Name Type Description
seriesKey Object

The series identifier by which the color is selected.

palette Palette

The chart’s current palette.

Returns

Type Description
Color

The color assigned to the specified series identifier.

Example

The following code demonstrates how to implement a custom colorizer that should paint series using a non-predefined algorithm:

class CustomSeriesColorizer : SeriesColorizer {
    List<object> metColors = new List<object>();

    public override Color GetSeriesColor(object seriesKey, Palette palette) {
        int keyIndex;
        if (metColors.Contains(seriesKey)) {
            keyIndex = metColors.IndexOf(seriesKey);
        } else {
            keyIndex = metColors.Count;
            metColors.Add(seriesKey);
        }
        return palette[keyIndex % palette.Count].Color;
    }

    protected override ChartElement CreateObjectForClone() {
        return new CustomSeriesColorizer();
    }
}
See Also