KeyColorColorizer.Keys Property
Gets or sets the collection of keys used by the KeyColorColorizer.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
ColorizerKeysCollection | A collection of keys of the Object type. |
Example
To configure and use the Key-Color colorizer, perform the following steps.
- Create a KeyColorColorizer object and assign it to the Series.Colorizer property.
- Populate 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 used to provide keys based on the color data source member.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-colorize-charts-using-the-key-color-colorizer-t245294.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
x:Class="KeyColorColorizer.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:ChartControl.Legend>
<dxc:Legend/>
</dxc:ChartControl.Legend>
<dxc:XYDiagram2D>
<dxc:BarSideBySideSeries2D DisplayName="GDP"
DataSource="{Binding XPath=/G20HPIs/CountryStatistics}"
ArgumentDataMember="Country" ValueDataMember="Product"
ColorDataMember="Region">
<dxc:BarSideBySideSeries2D.Colorizer>
<dxc:KeyColorColorizer>
<dxc:KeyColorColorizer.Keys>
<sys:String>Africa</sys:String>
<sys:String>America</sys:String>
<sys:String>Asia</sys:String>
<sys:String>Australia</sys:String>
<sys:String>Europe</sys:String>
</dxc:KeyColorColorizer.Keys>
<dxc:KeyColorColorizer.Palette>
<dxc:Office2013Palette/>
</dxc:KeyColorColorizer.Palette>
</dxc:KeyColorColorizer>
</dxc:BarSideBySideSeries2D.Colorizer>
</dxc:BarSideBySideSeries2D>
</dxc:XYDiagram2D>
</dxc:ChartControl>
</Grid>
</Window>
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Keys 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.