如何在Xamarin.Android中使用OxyPlot创建环形图?

3

我需要创建一个像Highcharts一样显示图表的应用程序。但是我没有找到任何相关库。因此,我正在使用oxyplot来创建图表。我已经使用oxyplot创建了饼图,如下所示。

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;
    }

但现在我需要创建带有点击监听器和点击效果的环形图表。我该如何做呢?
提前感谢。
1个回答

6

@Nisar Ahmad 使用OxyPlot库制作环形图的代码如下。

    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;

    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接