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

How can i make customization Doughtnut chart slice as i want color

Thread ID:

Created:

Updated:

Platform:

Replies:

145891 Jul 12,2019 07:18 AM UTC Jul 15,2019 07:29 AM UTC Xamarin.Forms 1
loading
Tags: SfChart
Mahmut Nedim
Asked On July 12, 2019 07:18 AM UTC

I want to change colors of the slices as I want as follows. How can i add another property for color in ChartDataModel and how can i make binding. Thank u

Rachel A [Syncfusion]
Replied On July 15, 2019 07:29 AM UTC

Hi Mahmut, 
 
Greetings from Syncfusion. 
 
We can achieve this requirement by setting custom palette to series with the required colors. Also, have prepared a sample based on the requirement and it can download from the below link. 
 
 
Please find the code snippet below to achieve the same. 
 
[XAML]: 
<chart:SfChart.Series> 
    <chart:DoughnutSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue" > 
         <chart:DoughnutSeries.ColorModel> 
            <chart:ChartColorModel Palette="Custom" CustomBrushes="{Binding Colors}" /> 
         </chart:DoughnutSeries.ColorModel> 
    </chart:DoughnutSeries> 
</chart:SfChart.Series> 
 
 
[C#]: 
public class ViewModel 
{ 
    public ChartColorCollection Colors { get; set; } 
    public ViewModel() 
    { 
        Colors = new ChartColorCollection(); 
        Colors.Add(Color.Red); 
        Colors.Add(Color.DarkViolet); 
        Colors.Add(Color.GreenYellow); 
        Colors.Add(Color.Blue); 
    } 
} 
 
 
Output: 
 
 
Please refer below user documentation to know more details about custom palette.   
 
 
Please let us know if you have any queries.   
 
Regards, 
Rachel. 
 


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