Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh oxyplot plot when data changes

Tags:

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.

like image 707
Jkallus Avatar asked Jan 04 '14 22:01

Jkallus


2 Answers

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) 
like image 98
ruttopia Avatar answered Sep 18 '22 15:09

ruttopia


Give x:Name to OxyPlot instance in XAML:

<oxy:Plot x:Name="Plot1"/> 

and on button click handler, refresh like this:

private void RefreshButton_Click(object sender, RoutedEventArgs e) {    Plot1.RefreshPlot(true); } 
like image 25
Rohit Vats Avatar answered Sep 16 '22 15:09

Rohit Vats