0

I am trying to update my chart in some cases. I call the Plot methot with in another method. I found this solution but it is for textBox so I can't implement it to my code. I searched on the internet but I couldn't find a solution for charts.

How can I solve this problem for adding points to a chart?

private void Plot()
    {
            chart1.Series["test1"].Points.AddXY
                            (plotValues[0,1], plotValues[0,0]);
            chart1.Series["test1"].Points.AddXY
                           (plotValues[1, 1], plotValues[1, 0]);

    }
Community
  • 1
  • 1
ffttyy
  • 853
  • 2
  • 19
  • 49

1 Answers1

0
Dispatcher.Invoke(() => chart1.Series["test1"].Points.AddXY
                        (plotValues[0,1], plotValues[0,0]));

(or InvokeAsync in case you want to run is async / don't need to wait for the operation to be finished on your other thread)

Bogey
  • 4,926
  • 4
  • 32
  • 57