Reputation: 2067
I need to create app that shows chart like Highcharts. But i did't get any library for that. So i'm using oxyplot to create charts. I have create pie chart using oxyplot like this.
var plotView = new PlotView (this);
plotView.Model = PieViewModel();
this.AddContentView (plotView,
new ViewGroup.LayoutParams (ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
public PlotModel PieViewModel()
{
var modelP1 = new PlotModel { Title = "Pie Sample1" };
dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.8, AngleSpan = 360, StartAngle = 0 };
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);
return modelP1;
}
But now i need create doughnut chart with click listeners and effects on click. How can i do this?
Thanks in Advance
Upvotes: 3
Views: 2344
Reputation: 136
@Nisar Ahmad Find the below codes using oxyplot libraries for doughnut chart.
public static PlotModel Simplemodel()
{
var modelP1 = new PlotModel { Title = "Pie Sample1" };
dynamic seriesP1 = new PieSeries { StrokeThickness = 2.0, InsideLabelPosition = 0.5, AngleSpan = 360, StartAngle = 0, InnerDiameter = 0.4 };
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);
return modelP1;
}
Upvotes: 6