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.
Unfortunately, activation email could not send to your email. Please try again.

change color of Piechart

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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

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

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 04:26 AM

Thanks Manivannan E. 

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

lakhwinder
Replied On November 3, 2015 04:36 AM

Thanks Manivannan Elangovan,
its works perfect

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

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 12:23 AM

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 12:34 PM

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.

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.

;