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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfChart PieSeries color

Thread ID:

Created:

Updated:

Platform:

Replies:

148378 Oct 17,2019 08:01 AM UTC Oct 19,2019 05:17 AM UTC Xamarin.Forms 3
loading
Tags: SfChart
Vito Feleppa
Asked On October 17, 2019 08:01 AM UTC

Hi,

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

Thanks,
Vito

Hemalatha Marikumar [Syncfusion]
Replied On 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.
 


Vito Feleppa
Replied On October 18, 2019 10:27 AM UTC

Hi,

Ok thanks, I achieved the requirement.

Best regards,
Vito

Hemalatha Marikumar [Syncfusion]
Replied On 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. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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

Live Chat Icon For mobile
Live Chat Icon