Chart for WinRT
Customizing the Color Palette

To change the colors assigned to the plot elements such as bars and pies(depending on chart type), you can either change the C1Chart.Palette property to one of the predefined color palettes or you can create a custom palette, using either code or XAML Markup.

In markup, you'll create a custom style that contains the custom palette colors:

XAML
Copy Code
<Style TargetType="c1:C1Chart">
     <Setter Property="CustomPalette">
         <Setter.Value>
             <ResourceDictionary>
                 <SolidColorBrush x:Key="0" Color="#16ABA9"/>
                 <SolidColorBrush x:Key="1" Color="#EB7A2A"/>
                 <SolidColorBrush x:Key="2" Color="#F2CA04"/>
                 <SolidColorBrush x:Key="3" Color="#DC5B20"/>
                 <SolidColorBrush x:Key="4" Color="#8EBC00"/>
                 <SolidColorBrush x:Key="5" Color="#25A0DA"/>
                 <SolidColorBrush x:Key="6" Color="#25A0DA"/>
                 <SolidColorBrush x:Key="7" Color="#309B46"/>
                 <SolidColorBrush x:Key="8" Color="#24C6D2"/>
                 <SolidColorBrush x:Key="9" Color="#8A8065"/>
             </ResourceDictionary>
         </Setter.Value>
     </Setter>
 </Style>

 

In code, you can simply set the custom palette in one of two ways. You can either create a new SolidColorBrush series and set colors using RGB values:

C#
Copy Code
// set custom palette
SolidColorBrush[] customPalette = new SolidColorBrush[3];
customPalette[0] = new SolidColorBrush(Color.FromArgb(255, 2, 186, 2));
customPalette[1] = new SolidColorBrush(Color.FromArgb(255, 2, 140, 186));
customPalette[2] = new SolidColorBrush(Color.FromArgb(255, 2, 78, 186));
c1Chart1.CustomPalette = customPalette;
               

or you can set the CustomPalette directly and simply name the colors you'd like to use:

C#
Copy Code
c1Chart.CustomPalette = new SolidColorBrush[]
   {
     new SolidColorBrush(Colors.Red),
     new SolidColorBrush(Colors.Yellow),
     new SolidColorBrush(Colors.Orange),
   };

 

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback