未生成xamarin中的Oxyplot

未生成xamarin中的Oxyplot,xamarin,oxyplot,Xamarin,Oxyplot,我遇到了用动态数据生成oxyplot的问题。这是我第一次在动态数据中使用oxyplot public async Task<PlotModel> AreaChart_NoOfPoliciesAsync() { var plotModel1 = new PlotModel { Title = "Number of Policies with last year" }; plotModel1.InvalidatePlot(true);

我遇到了用动态数据生成oxyplot的问题。这是我第一次在动态数据中使用oxyplot

public async Task<PlotModel> AreaChart_NoOfPoliciesAsync()
    {
        var plotModel1 = new PlotModel { Title = "Number of Policies with last year" };

        plotModel1.InvalidatePlot(true);
        try
        {


            var s1 = new AreaSeries()
            {
                Title = "Number of policies in last year",
                Color = OxyColors.LightPink,
                MarkerType = MarkerType.Circle,
                MarkerSize = 6,
                MarkerStroke = OxyColors.White,
                MarkerFill = OxyColors.LightPink,
                MarkerStrokeThickness = 1.5
            };

            string year_str = DateTime.Today.AddYears(-1).ToString("yyyy");
            int running_month = 1;
            string running_month_str;

            List<MonthlyPerformance> last_year = await _apiServices.GetMonthlyPerformance(Settings.AccessToken, Settings.agentCode, year_str);

            last_year = last_year.FindAll(x => x.BUSS_TYPE == "Total");
            last_year.Sort((x, y) => x.Y_MONTH.CompareTo(y.Y_MONTH));


            s1.Points.Add(new DataPoint(0, 0));
    foreach (MonthlyPerformance item in last_year)
            {
        s1.Points.Add(new DataPoint(running_month, item.NO_BUSINESS));
        running_month++;
    }
    plotModel1.Series.Add(s1);

            plotModel1.Axes.Add(new LinearAxis { Position = AxisPosition.Left, IsPanEnabled = false, IsZoomEnabled = false });
            plotModel1.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, IsPanEnabled = false, IsZoomEnabled = false });

    return plotModel1;}
public async Task AreaChart\u NoOfPoliciesAsync()
{
var plotModel1=新的PlotModel{Title=“去年的保单数量”};
plotModel1.InvalidatePlot(真);
尝试
{
变量s1=新区域系列()
{
Title=“去年保单数量”,
颜色=氧色。浅粉色,
MarkerType=MarkerType.Circle,
MarkerSize=6,
MarkerStroke=氧色。白色,
MarkerFill=OxyColors.LightPink,
MarkerStrokeThickness=1.5
};
字符串year_str=DateTime.Today.AddYears(-1).ToString(“yyyy”);
int running_月=1;
字符串运行\u月\u str;
List last_year=wait_apiServices.GetMonthlyPerformance(Settings.AccessToken、Settings.agentCode、year_str);
上一年=上一年.FindAll(x=>x.BUSS_TYPE==“总计”);
上一年。排序((x,y)=>x.y\u月。与(y.y\u月)相比);
s1.点。添加(新数据点(0,0));
foreach(上年度月度绩效项目)
{
s1.点数.添加(新数据点(运行月份,项目.无业务));
运行月++;
}
plotModel1.Series.Add(s1);
plotModel1.Axes.Add(新的LinearAxis{Position=AxisPosition.Left,IsPanEnabled=false,IsZoomEnabled=false});
plotModel1.Axes.Add(新的LinearAxis{Position=AxisPosition.Bottom,IsPanEnabled=false,IsZoomEnabled=false});
返回plotModel1;}
使用用于演示的硬编码值生成的绘图。但是当函数

 List<MonthlyPerformance> last_year = await _apiServices.GetMonthlyPerformance(Settings.AccessToken, Settings.agentCode, year_str);
List last\u year=wait\u apiServices.GetMonthlyPerformance(Settings.AccessToken、Settings.agentCode、year\u str);
调用时,没有生成oxyplot。我只得到一个空格。我没有得到任何编译错误

我正在使用MVVM。有人能指出我在这里做错了什么吗。
提前感谢。

一旦wait和async被删除,图表就会出现


我认为这不是处理该问题的正确方法。但我的开发时间快用完了。

如何使用返回的plotModel1?是否缺少更新属性的通知,因此视图不会刷新?