How to refresh oxyplot plot when data changes

Jkallus picture Jkallus · Jan 4, 2014 · Viewed 35.4k times · Source

GUI for the program

Oxyplot graphs 13 points which are derived from the 6 user input text boxes. The values in the text boxes are held in public variables in the MainWindow.xaml.cs class. The variables are updated when the user presses enter in the text box. How would I make the refresh button refresh the graph.

private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            //Refresh The Graph
        }

I think that this would be done using the

PlotModel.RefreshPlot() 

method, but I am not sure how to implement it because of Oxyplot's poor documentation.

Answer

ruttopia picture ruttopia · Apr 10, 2014

I just updated to a new version of OxyPlot via NuGet. I'm using OxyPlot.Wpf v20014.1.277.1 and I think you now need to call InvalidatePlot(bool updateData) on the PlotModel instead of RefreshPlot (which is no longer available). I tested this in my sample code and it worked as expected.

If you want to refresh the plot and update the data collections, you need to pass true to the call:

PlotModel.InvalidatePlot(true)