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

change color of Piechart

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

6 Replies

ME Manivannan Elangovan Syncfusion Team 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


RG Rupreet Gujral November 3, 2015 09:26 AM UTC

Thanks Manivannan E. 

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


LA lakhwinder November 3, 2015 09:36 AM UTC

Thanks Manivannan Elangovan,
its works perfect


ME Manivannan Elangovan Syncfusion Team 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


MB Marco Bruno Ferreira Vasconcellos replied to Manivannan Elangovan 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>



PS Parthiban Sundaram Syncfusion Team 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
 
 


Loader.
Live Chat Icon For mobile
Up arrow icon