1
votes

I'm using OxyPlot in my wpf application as line recorder. It's like the LiveDemo example. On a larg visible data set, I get some UI performance issues and may the whole application could freez. It seems to be PlotModel.InvalidatePlot which is called with to many points to often, but I didn't found a better way.

In deep:

  • Using OxyPlot 2.0.0
  • I code all in the PlotModel. The Xaml PlotView is only binding to the PlotModel.
  • I cyclical collect data in a thread an put them in a DataSource (List of List which are ItemSoure for the LineSeries)
  • I have a class which calculates cyclical in a thread the presentation for x and y axis and a bit more. After all this stuff, it calls PlotModel.InvalidatePlot.

If I

  • have more than 100 k points on the display (no matter if in multiple LineSeries or not)
  • and add 1 DataPoint per LineSeries every 500 ms
  • and call PlotModel.InvalidatePlot every 200 ms

not only the PlotView has performance issues, also the window is very slow in reaction, even if I call PlotModel.InvalidatePlot (false).

My goal

My goal would be that the Windo / Application is working normally. It should not hang up because of a line recorder. The best would be if it has no performance issues, but I'm skeptical.

What I have found or tested

OxyPlot has Performance guidelines. I'm using ItemsSource with DataPoints. I have also tried adding them directly to the LineSeris.Points, but then the Plot doesn’t refresh anyway (even with an ObservableCollection), so I have to call PlotModel.InvalidatePlot, what results in the same effect. I cannot bind to a defined LineSeries in Xaml because I don’t know how much Lines will be there. Maybe I missed something on adding the points directly?

I have also found a Github issue 1286 which is describing a related problem, but this workaround is slower in my tests.

I have also checked the time which is elapsed on the call of PlotModel.InvalidatePlot, but the count of points does not affect it.

I have checked the UI thread and it seems it have trouble to handle this large set of points

LargepointSet

If I zoom in to the plot and display under 20 k Points it looks so

Zoomed

Question:

Is there a way to handle this better, except to call PlotModel.InvalidatePlot much less?

Restrictions:

I also must Update Axis and Annotations. So, I think I will not come around to call PlotModel.InvalidatePlot.

2

2 Answers

0
votes

For the moment I ended up with calculating the time for calling InvalidatePlot for the next time. I calculate it with the method given in this answer, wich returns the number of visible points. This rededuce the performance issue, but dosent fix the block on the UI Thread on calling InvalidatePlot.

0
votes

I have found that using the OxyPlot Windows Forms implementation and then displaying it using Windows Form integration in WPF gives much better performance.

e.g.

var plotView = new OxyPlot.WindowsForms.PlotView();
plotView.Model = Plot;

var host = new System.Windows.Forms.Integration.WindowsFormsHost();
host.Child = plotView;

PlotContainer = host;

Where 'Plot' is the PlotModel you call InvalidatePlot() on.

And then in your XAML:

<ContentControl Content="{Binding PlotContainer}"/>

Or however else you want to use your WindowsFormsHost.