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

Assign colors to Chart DougnutSeries Items based on value

I'm using Xamarin.Forms.

I found this post which I've used to define colors for the pieces of the doughnut series: http://www.syncfusion.com/forums/120998/change-color-of-Piechart, however, I would like to know if it is possible to specify the color of a piece based on the value. For example, I have two sets of items; GOOD and BAD, and I'd like to make sure the GOOD section is Green and the BAD section is Red. In other examples, I may have 3 parts to the pie and want the third OTHER part to be LightBlue. Do you have any examples on how to do this, I'm assuming involving Binding Converters?

Thank you,

John

3 Replies

JR John Rennemeyer December 7, 2015 04:21 PM UTC

If at all possible, I'd prefer any examples to be in XAML. Thanks!


JR John Rennemeyer December 7, 2015 04:23 PM UTC

In regards to my previous comment, I wanted to clarify that as much as can be done, be done in XAML, while those things that obviously cannot be done in XAML (for example, converters) are fine.


SB Suresh B Syncfusion Team December 8, 2015 08:45 AM UTC

Hi John Rennemeyer,

 

Thanks for using Syncfusion products.

 

We have prepared the sample for your requirement. In this sample, we have generated the color value for the each data point and bound it with the CustomBrushes property of the ChartColorModel. Please find the sample from the below location.

 

CodeExample:

 

<chart:DoughnutSeries.ColorModel>

         

    <chart:ChartColorModel Palette="Custom" CustomBrushes="{Binding Colors}"/>

           

 </chart:DoughnutSeries.ColorModel>

 

Sample: DoughnutSeries

 

Regards,

 

Suresh B.


Loader.
Live Chat Icon For mobile
Up arrow icon