簡體   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