我需要创建像 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; 
    } 

但现在我需要创建带有点击监听器和点击效果的圆环图。 我怎样才能做到这一点?

提前致谢

请您参考如下方法:

@尼萨尔艾哈迈德 使用用于圆环图的 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; 
 
    } 


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!