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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

change color of Piechart

Thread ID:

Created:

Updated:

Platform:

Replies:

120998 Nov 2,2015 07:02 AM UTC Sep 5,2017 04:34 PM UTC Xamarin.iOS 6
loading
Tags: SfChart
lakhwinder
Asked On November 2, 2015 07:02 AM UTC

How to change the color of pie chart in Xamarin.iOS

Manivannan Elangovan [Syncfusion]
Replied On November 2, 2015 11:15 AM UTC

Hi Lakhwinder,

We can achieve your requirement by using the property ColorModel in the Series. Refer to the following code example which shows how to set ColorModel in series.

CodeExample:

SFPieSeries series = new SFPieSeries ();
series.ColorModel.Palette = SFChartColorPalette.Custom;
NSObject[] cusColors = new NSObject[] {UIColor.Blue,UIColor.Green,UIColor.Orange,UIColor.Red,UIColor.Cyan};
series.ColorModel.CustomColors = NSArray.FromNSObjects(cusColors);
series.DataMarker.ShowLabel = true;
return series;

We have prepared a sample based on your requirement. Please find the sample from the following location.

Sample: PieChart

Regards,
Manivannan.E

Rupreet Gujral
Replied On November 3, 2015 09:26 AM UTC

Thanks Manivannan E. 

It worked for me , thanks once again for your great help

lakhwinder
Replied On November 3, 2015 09:36 AM UTC

Thanks Manivannan Elangovan,
its works perfect

Manivannan Elangovan [Syncfusion]
Replied On November 4, 2015 11:26 AM UTC

Hi Lakhwinder,

Thanks for the update. Please let us know if you have any query.

Regards,
Manivannan.E

Marco Bruno Ferreira Vasconcellos
Replied On September 4, 2017 04:23 AM UTC

Hi Lakhwinder,

We can achieve your requirement by using the property ColorModel in the Series. Refer to the following code example which shows how to set ColorModel in series.

CodeExample:

SFPieSeries series = new SFPieSeries ();
series.ColorModel.Palette = SFChartColorPalette.Custom;
NSObject[] cusColors = new NSObject[] {UIColor.Blue,UIColor.Green,UIColor.Orange,UIColor.Red,UIColor.Cyan};
series.ColorModel.CustomColors = NSArray.FromNSObjects(cusColors);
series.DataMarker.ShowLabel = true;
return series;

We have prepared a sample based on your requirement. Please find the sample from the following location.

Sample: PieChart

Regards,
Manivannan.E

I did it in XAML:


<chart:PieSeries ItemsSource="{Binding HighTemperature}" >

                        <chart:PieSeries.ColorModel>

                            <chart:ChartColorModel Palette="Custom" >

                                <chart:ChartColorModel.CustomBrushes>

                                    <Color>

                                        Red

                                    </Color>

                                    <Color>

                                        Yellow

                                    </Color>

                                    <Color>

                                        Green

                                    </Color>

                                </chart:ChartColorModel.CustomBrushes>

                            </chart:ChartColorModel>

                        </chart:PieSeries.ColorModel>

                        

                        

                        <chart:PieSeries.DataMarker>

                            <chart:ChartDataMarker ShowLabel="True"></chart:ChartDataMarker>

                        </chart:PieSeries.DataMarker>


                    </chart:PieSeries>


Parthiban Sundaram [Syncfusion]
Replied On September 5, 2017 04:34 PM UTC

Hi Macro, 
 
We have prepared the sample based on your provided code snippet to change the color of PieChart. Please find the sample from following location. 
 
 
Custom Brushes: 
 
ChartSeries will use the colors from CustomBrushes property if the ColorModel.Palette property of series is set to Custom 
 
Also, you can change the PieChart color using predefined palettes available in ColorModel property of ChartSeries as listed below. 
 
1.     Metro 
2.     TomatoSpectrum 
3.     Pineapple 
4.     None 
 
Please find the below code snippet for more details. 
 
Code Snippet: 
 
  
      <chart:PieSeries.ColorModel> 
        <chart:ChartColorModel Palette=" TomatoSpectrum" > 
     </chart:PieSeries.ColorModel> 
 
 
Please let us know, if you need further assistance on this.   
 
Regards,
Parthiban S
 
 


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.

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

;