Category / Section
How to set color for the series ColorModel property?
1 min read
Description:
This article describes how to apply color for the series ColorModel property.
Solution:
You can apply color by adding the custom brushes to the ChartColorModel as shown in the following code example.
C#
ChartColorModel colorModel = new ChartColorModel();
colorModel.CustomBrushes.Add(new SolidColorBrush(Colors.Red));
colorModel.CustomBrushes.Add(new SolidColorBrush(Colors.RosyBrown));
colorModel.CustomBrushes.Add(new SolidColorBrush(Colors.RoyalBlue));
colorModel.CustomBrushes.Add(new SolidColorBrush(Colors.SaddleBrown));
colorModel.CustomBrushes.Add(new SolidColorBrush(Colors.Salmon));
chart.Series[0].Palette = ChartColorPalette.Custom;
chart.Series[0].ColorModel = colorModel;
XAML
<syncfusion:ColumnSeries ItemsSource="{Binding TestingModel}"
XBindingPath="X" YBindingPath="Y1" Palette="Custom">
<syncfusion:ColumnSeries.ColorModel>
<syncfusion:ChartColorModel>
<syncfusion:ChartColorModel.CustomBrushes>
<SolidColorBrush Color="Red"/>
<SolidColorBrush Color="RosyBrown"/>
<SolidColorBrush Color="RoyalBlue"/>
<SolidColorBrush Color="SaddleBrown"/>
<SolidColorBrush Color="Salmon"/>
</syncfusion:ChartColorModel.CustomBrushes>
</syncfusion:ChartColorModel>
</syncfusion:ColumnSeries.ColorModel>
</syncfusion:ColumnSeries>