繁体   English   中英

OxyPlot,点不在LineSeries中

[英]OxyPlot, Points not in LineSeries

我很难让OxyPlot在独立的WPF应用程序中显示我的数据(我使用caliburn micro,并遵循MVVM模式)。

所以在我的Xaml中,我有以下内容:

<UserControl ...
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf">

然后

<oxy:Plot Title="Winnings of Selected Player" Model="{Binding Graph1}"/>

在我的ViewModel中,我似乎可以选择using OxyPlot; using OxyPlot.Wpf; 如果使用前者,则可以如下定义我的PlotModel

private PlotModel _graph1;
public PlotModel Graph1 { 
    get { return _graph1;} 
    set { 
        _graph1 = value;
        Graph1.RefreshPlot(true);
    }
}

public MyViewModel() {

    Graph1 = new PlotModel();
    var FirstSeries = new LineSeries();
    FirstSeries.Points.Add(new DataPoint(1,2));
    FirstSeries.Points.Add(new DataPoint(1,2));

}

但我的视图没有显示任何内容(实际上,我什至看不到“空图”或视图中的标题)。 我也尝试在整个地方分散RefreshPlot命令...

因此,我想尝试using OxyPlot.Wpf; 代替。 然后,但是,我无法将Points添加到LineSeries -这是我的IntelliSense的屏幕截图...

!( http://imageshack.com/a/img30/2441/cvqy.png

那么,如何使用OxyPlot.Wpf将数据填充到LineSeries中? 顺便说一句,即使我在未向LineSeries添加点的情况下进行编译,我仍然看不到空图。 我看过的所有示例都执行此操作,或者他们在我不想执行的.xaml.cs代码隐藏文件中编写代码。

编辑:正如dellywheel所提到的,当我问问题时,我忘记将LineSeries添加到上述PlotModel中,因此上述构造函数应包含该行

Graph1.Series.Add(FirstSeries);

但这只是在输入问题,不是真正的问题...

您尚未将LineSeries添加到图,并且图是Graph1而不是Graph试试

public MyViewModel(){
     Graph1 = new PlotModel();
     var firstSeries = new LineSeries();
     firstSeries.Points.Add(new DataPoint(1, 2));
     firstSeries.Points.Add(new DataPoint(1, 2));
     Graph1.Series.Add(firstSeries);
  }

希望能有所帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM