Closed Developer-Alexander closed 1 year ago
Thanks for the sample! this issue is also related to #1048.
When the timer callback is called, it is not running in the UI thred, thus you can get this exception, please take a look here: https://github.com/beto-rodriguez/LiveCharts2/issues/225#issuecomment-1012488255 there is more explanation about this.
In this case you can fix it by forcing the update to happen in the UI thread:
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Dispatcher.UIThread.Post(() =>
{
if (currentId >= 200000000)
{
return;
}
DateTime now = DateTime.UtcNow;
IDisposable notificationSuspender = Values.SuspendNotifications();
for (int i = 0; i < 100; i++)
{
Values.Add(new(now + TimeSpan.FromMilliseconds(i / 100.0), 1.0));
}
notificationSuspender.Dispose();
});
}
Thank you. That's helpful. I would choose Alternative 2 (https://github.com/beto-rodriguez/LiveCharts2/issues/225#issuecomment-1012488255) as it remove some load from the UI thread.
However the longer the source collection get the less responsive the chart and the UI gets. Is there some kind of virtualisation, slicing or downsampling mechanism that helps keep the UI fluid?
I was trying to downsample the (frequently updating) input data depending on the currently visible part given by MinLimit
and MaxLimit
of the XAxis
. But it did not work out yet. I would be very thankful for some tips.
There is an experimental virtualization algorithm for the library.
https://github.com/beto-rodriguez/LiveCharts2/releases/tag/v2.0.0-beta.350
It helps a lot, soon it should be public for everyone.
That sounds great! Please do not hesitate to release it very soon.
I hope to do so!
For now, I will close this, thanks for the report.
How do I know when the feature gets available?
Any update on this?
Describe the bug When the Valus of a series are updated very frequently via an observable collection the Avalonia App crashes with Collection was modified; enumeration operation may not execute..
The version of Avalonia that is used is 11.0.0-rc1.1. The version of LiveChartsCore.SkiaSharpView.Avalonia that is used is 2.0.0-beta.700-11.0.0-rc1.1.
To Reproduce See attached minimal example. ChartTest.zip
Expected behavior I would expect that there is some kinf of throtteling or debouncing to prevent crahes in case of frequent value updates.
Desktop (please complete the following information):