Oxyplot图形占用整个屏幕进行显示 [英] Oxyplot graph takes up whole screen for display

查看:95
本文介绍了Oxyplot图形占用整个屏幕进行显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始在我的项目中使用oxyplot库.我已在项目中成功添加了一个甜甜圈图,但是这样做的问题是它占用了整个屏幕来显示图形.尝试了很多方法来解决此问题,但没有一个起作用.

I just started using using oxyplot library for my project. I successfully added a donut chart in my project but the problem with this is that it takes up the whole screen to show the graph. Is tried so many way to solve this but none of them worked.

这是我的axml:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    local:layout_behavior="@string/appbar_scrolling_view_behavior" >
    <OxyPlot.Xamarin.Android.PlotView
        android:id="@+id/plot_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        local:MvxBind="Model DonutChart"/>
    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="16dp"
            local:MvxBind="Text TestText1" />
    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="16dp"
            local:MvxBind="Text TestText2" />
    <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="16dp"
            local:MvxBind="Text TestText3" />
</LinearLayout>

以下是图形方法:

private void GeneratePlotModel()
    {
        var plotmodel = new PlotModel();

        var seriesP1 = new PieSeries
        {
            Stroke = OxyColors.Transparent,
            StrokeThickness = 2.0,
            InsideLabelPosition = 0.0,
            AngleSpan = 360,
            StartAngle = 0,
            InnerDiameter = 0.7,
            OutsideLabelFormat = null,
            InsideLabelFormat = null,
            TickHorizontalLength = 0.0,
            TickRadialLength = 0.0
        };

        seriesP1.Slices.Add(new PieSlice("Test 1", test1) { IsExploded = false, Fill = OxyColors.Blue });
        seriesP1.Slices.Add(new PieSlice("Test 2", test2) { IsExploded = false, Fill = OxyColors.Green });
        seriesP1.Slices.Add(new PieSlice("Test 3", test3) { IsExploded = false, Fill = OxyColors.Red });

        plotmodel.Series.Add(seriesP1);

        DonutChart = plotmodel;
    }

这是我的plotmodel属性:

Here is my plotmodel property:

private PlotModel _donutChart ;
    public PlotModel DonutChart 
    {
        get => _donutChart ;
        set
        {
            if (_donutChart == value)
                return;

            _donutChart = value;
            RaisePropertyChanged(nameof(DonutChart ));
        }
    }

推荐答案

由于设置了

android:layout_width="match_parent"
android:layout_height="match_parent"

您可以通过添加

android:layout_weight="1"

所以布局是这样的:

<OxyPlot.Xamarin.Android.PlotView
        android:id="@+id/plot_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        local:MvxBind="Model DonutChart"/>

这篇关于Oxyplot图形占用整个屏幕进行显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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