Issue is only present on iOS. Android and windows work as expected.
When using a ScatterLineSeries with a ItemSource set to an ObservableCollection the Chart control has a tendency to hang and lock the application when the ObservableCollection data slides (items are removed at position 0, and items are added to the end)
When the issue occurs iOS Device log has entries such as:
"default 09:31:45.095875-0500 myApp.Client.Mobile Hang detected: 0.39s (always-on hang reporting)"
//this is called once during the setup of the control
var data = new ObservableCollection<SeriesData>();
ScatterLineSeries lineSeries = new ScatterLineSeries()
{
DisplayName = series.Name,
XValueBinding = new PropertyNameDataPointBinding(nameof(SeriesData.XScaled)),
YValueBinding = new PropertyNameDataPointBinding(nameof(SeriesData.YScaled)),
ItemsSource = data,
};
chart.Series.Add(lineSeries);
//this is called periodically as new data is available to display
public void AddSeriesData(IEnumerable<SeriesData> data)
{
float? min = null;
float? max = null;
lock (_data)
{
foreach (var d in data)
{
d.XScaled = d.X;
d.YScaled = ((d.Y ?? 0) - d.Series.MinValue) / (d.Series.MaxValue - d.Series.MinValue) * 100;
if (_data.TryGetValue(d.Series, outvar collection))
{
collection.Add(d);
max = d.XScaled;
min = collection[0].XScaled;
while (max - min > settings.XAxisRange)
{
//application will start to hang here, once items are removed from beginning of the collection
collection.RemoveAt(0);
min = collection[0].XScaled;
}
}
}
}
if (max != null)
{
xAxis.Maximum = max.Value;
xAxis.Minimum = max.Value - settings.XAxisRange;
}
}
public class SeriesData
{
public readonly Series Series;
public readonly float? X;
public readonly float? Y;
public float? XScaled { get; internal set; }
public float? YScaled { get; internal set; }
public SeriesData(Series series, float? x, float? y)
{
Series = series;
X = x;
Y = y;
}
}
Hi Steve,
Could you please send me a sample project with implementation you have? I want to research the behavior by using the exact setup you have. Chat works with null values, still, I see you updated the min and max axis values runtime? Is this correct?
Hi Didi,
Please see the attached sample project as requested.
Testing on my iPad 10, after adding 4 to 6 series (add series by clicking the button), the app would be come slow to respond as soon as data reached the end of the chart and series data was removed from the source (observablecollection). Hang detections were also noted by watching the console log for the ipad while it's running.
Please let me know if you have any questions while you evaluate this sample.
Thanks,
Hi Steve,
Thank you for the provided file. Due to security reasons, may I ask you to attach the project to the forum, or open a support ticket and attach it there. You have support tickets you can use and you can write directly to the Telerik support by submitting support tickets.
I see the file size is a bit large. You can reduce its size by deleting bin and obj folders from the project, then archive it and attach it.
Note that I removed the google drive link from your reply.