Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Series.ColorDataMember Property

Gets or sets the name of the data member on which the color of a series point is based.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v24.2.dll

NuGet Package: DevExpress.Wpf.Charts

#Declaration

public string ColorDataMember { get; set; }

#Property Value

Type Description
String

A String value that is the name of a data member.

#Remarks

Note when a series template is used to generate series, you need to handle the ChartControl.BoundDataChanged event to set colors for all series when data is changed. To change colors one by one, handle the ChartControl.CustomDrawSeries event.

A data field specified by ColorDataMember can contain different data depending on the colorizer type.

For a ColorObjectColorizer, the data field can store the following values:

  • An integer ARGB color value (431493885)
  • Three, four, six, or eight digit hex code (#fc0, #f00f, #ff005d, #ff32cd32)
  • A string color name (SkyBlue)
  • A Color object
  • A SolidColorBrush object

For a KeyColorColorizer, the data field stores objects that are used as keys. Points with equal keys have the same color.

For a RangeColorizer, the data field stores numeric values. The colorizer determines to which interval the value belongs and assigns the corresponding color to the point.

#Example

To use the Color Object Colorizer, do the following.

Create a ColorObjectColorizer object and assign it to the Series.Colorizer property. Additional configuration is not required.

Note

This colorizer is used by default.

View Example

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" x:Class="ColorObjectColorizerExample.MainWindow"
        Title="MainWindow" Height="720" Width="1280">
    <Window.Resources>
        <XmlDataProvider x:Key="dataProvider" Source="Data/GDP.xml"/>
    </Window.Resources>

    <Grid DataContext="{Binding Source={StaticResource dataProvider}}">
        <dxc:ChartControl>
            <dxc:ChartControl.Titles>
                <dxc:Title Content="GDP for G20" HorizontalAlignment="Center"/>
            </dxc:ChartControl.Titles>
            <dxc:XYDiagram2D>
                <dxc:BarSideBySideSeries2D DisplayName="GDP" 
                                           DataSource="{Binding XPath=/G20HPIs/CountryStatistics}"
                                           ArgumentDataMember="Country" ValueDataMember="Product"
                                           ColorDataMember="NationalColor">
                    <dxc:BarSideBySideSeries2D.Colorizer>
                        <dxc:ColorObjectColorizer/>
                    </dxc:BarSideBySideSeries2D.Colorizer>
                </dxc:BarSideBySideSeries2D>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>

</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ColorDataMember property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also