2016-05-26 31 views
1

我已經使用wpf oxyplot並將x軸設置爲使用對數。當設置OxyPlot具有較大值的對數x軸並且PlotType設置爲使用笛卡爾選項時圖表曲線丟失

我使用mvvm沒有代碼風格。

這裏是我在虛擬機屬性

public PlotModel ChartPlot 
     { 
      get { return _chartPlot; } 
      set { _chartPlot = value; RaisePropertyChanged(() => ChartPlot); } 
     } 

WPF

<oxy:PlotView Grid.Row="1" Grid.Column="1" Model="{Binding ChartPlot}" /> 




//--- here is _bigDataPoints data list of points 

    var _bigDataPoints  = new List<DataPoints>(); 

//     #x1 double   #y double 

    _bigDataPoints.Add(410.8070281 , 4943000.0000000); 
    _bigDataPoints.Add(432.7935746 , 5041000.0000000); 
    _bigDataPoints.Add(436.8319199 , 5059000.0000000); 
    _bigDataPoints.Add(9918.193582 , 47320000.0000000); 
    _bigDataPoints.Add(10099.91912 , 48130000.0000000); 
    _bigDataPoints.Add(10216.58243 , 48650000.0000000); 
    _bigDataPoints.Add(104904.5616 , 470700000.0000000); 
    _bigDataPoints.Add(107282.6983 , 481300000.0000000); 
    _bigDataPoints.Add(108337.1551 , 486000000.0000000); 
    _bigDataPoints.Add(991388.6853 , 4422000128.0000000); 
    _bigDataPoints.Add(1000362.786 , 4462000128.0000000); 
    _bigDataPoints.Add(1006195.923 , 4488000000); 

    var logAxisX = new LogarithmicAxis() { Position = AxisPosition.Bottom, Title = "Log(x)", UseSuperExponentialFormat = false, Base = 10 }; 
    var linearAxisY = new LinearAxis() { Position = AxisPosition.Left, Title = "Y", UseSuperExponentialFormat = false }; 

// PlotModel ChartPlot = new PlotModel(); -> this is property that is binding to oxyplot control 

    ChartPlot.Axes.Add(linearAxisY); 
    ChartPlot.Axes.Add(logAxisX); 

    var lineSeriesBigData = new OxyPlot.Series.LineSeries(); 
    lineSeriesBigData.Points.AddRange(_bigDataPoints); 

    ChartPlot.Series.Clear(); 
    ChartPlot.Annotations.Clear(); 
    ChartPlot.Series.Add(lineSeriesBigData); 

// refresh chart 
ChartPlot.InvalidatePlot(true); 

曲線疏漏之處,爲什麼呢?我爲圖表軸設置了最小/最大間隔,但圖表上仍然存在線性曲線。其他bug是x軸不能用鼠標拖動。它看起來像軸凍結。如果我設置了最大的x軸,他不會在x軸上顯示正確的最大值。顯示100,爲什麼? y軸是OK

https://github.com/oxyplot/oxyplot/issues/900

回答

1

你缺少分配你的PlotModelPlotView,如下所示:

XAML:

<Window 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:local="clr-namespace:WpfApplication3" 
     xmlns:oxy="http://oxyplot.org/wpf" 
     x:Class="WpfApplication3.MainWindow" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"> 
    <Grid> 

     <oxy:PlotView Name="plotView1" Margin="0"/> 

    </Grid> 
</Window> 

CS:

private void Window_Loaded(object sender, RoutedEventArgs e) 
    { 
     var _bigDataPoints = new List<DataPoint>(); 

     // #x1 double #y double 

     _bigDataPoints.Add(new DataPoint(410.8070281, 4943000.0000000)); 
     _bigDataPoints.Add(new DataPoint(432.7935746, 5041000.0000000)); 
     _bigDataPoints.Add(new DataPoint(436.8319199, 5059000.0000000)); 
     _bigDataPoints.Add(new DataPoint(9918.193582, 47320000.0000000)); 
     _bigDataPoints.Add(new DataPoint(10099.91912, 48130000.0000000)); 
     _bigDataPoints.Add(new DataPoint(10216.58243, 48650000.0000000)); 
     _bigDataPoints.Add(new DataPoint(104904.5616, 470700000.0000000)); 
     _bigDataPoints.Add(new DataPoint(107282.6983, 481300000.0000000)); 
     _bigDataPoints.Add(new DataPoint(108337.1551, 486000000.0000000)); 
     _bigDataPoints.Add(new DataPoint(991388.6853, 4422000128.0000000)); 
     _bigDataPoints.Add(new DataPoint(1000362.786, 4462000128.0000000)); 
     _bigDataPoints.Add(new DataPoint(1006195.923, 4488000000)); 

     var logAxisX = new LogarithmicAxis() { Position = AxisPosition.Bottom, Title = "Log(x)", UseSuperExponentialFormat = false, Base = 10 }; 
     var linearAxisY = new LinearAxis() { Position = AxisPosition.Left, Title = "Y", UseSuperExponentialFormat = false }; 

     PlotModel ChartPlot = new PlotModel(); //-> this is property that is binding to oxyplot control 

     ChartPlot.Axes.Add(linearAxisY); 
     ChartPlot.Axes.Add(logAxisX); 

     var lineSeriesBigData = new OxyPlot.Series.LineSeries(); 
     lineSeriesBigData.Points.AddRange(_bigDataPoints); 

     ChartPlot.Series.Clear(); 
     ChartPlot.Annotations.Clear(); 
     ChartPlot.Series.Add(lineSeriesBigData); 

     // This is the line you're missing 
     plotView1.Model = ChartPlot; 
    } 

enter image description here

+0

我使用的mvvm沒有代碼風格。可能是bug與模式有關? public PlotModel ChartPlot { get {return _chartPlot; } set {_chartPlot = value; RaisePropertyChanged(()=> ChartPlot); } } Petar

+0

在這種情況下,您應該使用完整的XAML和'ViewModel '代碼。不要將它發佈在評論部分。 – jsanalytics

+0

請注意,在您的發佈代碼中,它不會顯示「ChartPlot」創建的位置,因爲它已被註釋掉。即使它沒有被註釋掉,它也被創建爲局部變量而不是公共屬性,這是'Binding'正常工作所必需的。 – jsanalytics

0

該錯誤與PlotType屬性相關

不使用笛卡爾!

相關問題