How to add an item one by one to a series in livechart

public ChartValues<ObservablePoint> Series1 { get; set; }

public void GeneratePlot(PlotInfo plotInfo)
{
    DataContext = null;

    Series1 = new ChartValues<ObservablePoint>();
    Series1.AddRange(plotInfo.SeriesIn);

    DataContext = this;
}

How can I add point 1 and wait 200 ms and add the next point smoothly?

Now the UI program stops for a few seconds and all points are displayed.

+4
source share
1 answer

Try the following:

public async void GeneratePlot(PlotInfo plotInfo)
{
    Series1 = new ChartValues<ObservablePoint>();
    DataContext = this;

    foreach (var x in plotInfo.SeriesIn)
    {
        Series1.Add(x);
        await Task.Delay(200);
    }
}
+1
source

Source: https://habr.com/ru/post/1695204/


All Articles