如何在Xamarin.android中使用oxyplot创建甜甜圈图? [英] How can i create doughnut chart using oxyplot in xamarin.android?

查看:83
本文介绍了如何在Xamarin.android中使用oxyplot创建甜甜圈图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建显示像Highcharts这样的图表的应用程序.但是我没有任何图书馆.所以我正在使用oxyplot创建图表.我已经使用oxyplot创建了饼图.

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?

预先感谢

推荐答案

@Nisar Ahmad 使用oxyplot库查找甜甜圈图,查找以下代码.

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

    }

这篇关于如何在Xamarin.android中使用oxyplot创建甜甜圈图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆