We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add custom color model to series?

Platform: WPF |
Control: SfChart |
Published Date: October 16, 2015 |
Last Revised Date: June 27, 2019

Description:

SfChart makes look of the chart good by supporting color customization. It helps you to color the series as per your requirement.

Solution:

The default color for the series is blue (#FF1BA1E2); it can be customized to any other color for the individual segments. This can be done by setting the Palette property to Custom. You can then define the required list of custom brushes, and assign them to the ColorModel property.

XAML

<chart:ColumnSeries Palette="Custom" XBindingPath="Label" YBindingPath="Price" ItemsSource="{Binding List1}">
  <chart:ColumnSeries.ColorModel>
     <chart:ChartColorModel>
         <chart:ChartColorModel.CustomBrushes>
             <SolidColorBrush Color="#FF245324"/>
             <SolidColorBrush Color="#FF202064"/>
             <SolidColorBrush Color="#FF7E1818" />
             <SolidColorBrush Color="#FF9C9C27"/>
             <SolidColorBrush Color="#FFAC6060"/>
             <SolidColorBrush Color="#FF4D8B85"/>
         </chart:ChartColorModel.CustomBrushes>
     </chart:ChartColorModel>
  </chart:ColumnSeries.ColorModel>
</chart:ColumnSeries>

 

C#

chart.Series[0].Palette = ChartColorPalette.Custom;
chart.Series[0].ColorModel.CustomBrushes = new List<Brush>();
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0x24, 0x53, 0x24)));
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0x20, 0x20, 0x64)));
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0x7E, 0x18, 0x18)));
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0x9C, 0x9C, 0x27)));
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0xAC, 0x60, 0x60)));
chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(250, 0x4D, 0x8B, 0x85)));

Output

Chart with custom color model applied in WPF

Figure 1: Custom brushes applied to segments.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon