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. Image for the cookie policy date
close icon

SfChart PieSeries color

Hi,

is possible to set the color of every item in a pie chart? If yes, how?

Thanks,
Vito

3 Replies

HM Hemalatha Marikumar Syncfusion Team October 17, 2019 01:42 PM UTC

Hi Vito Feleppa,

Greetings from Syncfusion.

Yes, you can set color for every item in PieSeries. You can achieve this requirement by setting the CustomBrushes which is available in ChartSeries. Please refer below code snippet. 
  
Code Snippet[Xaml]: 
<StackLayout.Resources> 
            <ResourceDictionary> 
                <chart:ChartColorCollection x:Key="Colors"> 
                    <Color>Red</Color> 
                    <Color>Gray</Color> 
                    <Color>Pink</Color> 
                    <Color> Blue</Color> 
                    <Color>YellowGreen</Color> 
                    <Color>Aqua</Color> 
              </chart:ChartColorCollection> 
            </ResourceDictionary> 
</StackLayout.Resources> 
  
<chart:SfChart.Series> 
               <chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue"> 
                <chart:PieSeries.ColorModel> 
                        <chart:ChartColorModel Palette="Custom" CustomBrushes="{StaticResource Colors}"/> 
              </chart:PieSeries.ColorModel> 
      </chart:PieSeries> 
</chart:SfChart.Series> 
  
Please refer below link to know more about the CustomBrushes. 
  
And we have prepared a sample based on your requirement and you can download the sample from the below link. 
  
  
Screenshot: 
 
  
Please let us know if need any further assistance. 
  
Regards,
Hemalatha M.
 



SS Seitron spa October 18, 2019 10:27 AM UTC

Hi,

Ok thanks, I achieved the requirement.

Best regards,
Vito


HM Hemalatha Marikumar Syncfusion Team October 19, 2019 05:17 AM UTC

Hi Vito Felepp, 
 
Thanks for your update. 
 
We glad to hear that given solution works. 
 
Please let us know if you have any other query. 
 
Regards, 
Hemalatha M. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon