0
votes

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

    }
1
What exactly is the problem with the answer in your link? - Margaret Bloom

1 Answers

0
votes
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)