1
votes

I have use wpf oxyplot and set x-axis to use logarithmic.

I use mvvm not code behind style.

here is my property in vm

 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);

Curve is missing at all, why? I have set min/max interval for chart axis but still linear curve is missing on the chart. other bug is that x-axis cannot be drag with mouse. it seem like axis is freeze. if I set maximum of x-axis he not show correct max value in x-axis. Show 100, why? y-axis is OK

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

2

2 Answers

1
votes

You are missing to assign your PlotModel to your PlotView, as follows:

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
votes

The bug is related with PlotType property

do not use Cartesian!!!