Search code examples
xamarin.formscross-platformpie-chart

Is Doughnut Pie chart possible in xamarin forms?


Is it possible to create a doughnut pie chart as shown below in xamarin forms(cross platform) using oxyplot or any other library.If yes can you help me with the link or example. I did find solution to implement pie chart but couldn't find solution to implement doughnut pie chart.

enter image description here

Any help is very much appreciated.


Solution

  • I finally found the solution to my answer by referring these below links:

    OxyPlot Piechart and How can i create doughnut chart using oxyplot in xamarin.android?

    public class SalesVM
    {
        private PlotModel modelP1;
        public SalesVM()
        {
            modelP1 = new PlotModel { Title = "Pie Sample1" };
    
            dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0, InnerDiameter = 0.8};
    
            seriesP1.Slices.Add(new PieSlice("Africa", 1030) { IsExploded = false, Fill = OxyColors.PaleVioletRed });
            seriesP1.Slices.Add(new PieSlice("Americas", 929) { IsExploded = true });
            seriesP1.Slices.Add(new PieSlice("Asia", 4157) { IsExploded = true });
            seriesP1.Slices.Add(new PieSlice("Europe", 739) { IsExploded = true });
            seriesP1.Slices.Add(new PieSlice("Oceania", 35) { IsExploded = true });
    
            modelP1.Series.Add(seriesP1);
    
        }
    
        public PlotModel Model1
        {
            get { return modelP1; }
            set { modelP1 = value; }
        }
    }