Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
DataChart not very effecient and takes 100% of cpu if single core.
posted

I am trying to update the chart in a single core machine at say 10hz. And I see the cpu jumps to 100%. So I tried to insert point efficently as using the RangeObservableClass to insert points to the observable collection tied to chart.

public class AddRangeObservableCollection<T> : ObservableCollection<T>
{
private bool _suppressOnCollectionChanged;

public void AddRange(IEnumerable<T> items)
{
if (null == items)
{
throw new ArgumentNullException("items");
}
if (items.Any())
{
try
{
_suppressOnCollectionChanged = true;
foreach (var item in items)
{
Add(item);
}
}
finally
{
_suppressOnCollectionChanged = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
}

protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!_suppressOnCollectionChanged)
{
base.OnCollectionChanged(e);
}
}
}

But when I use range to add points seems
like it is efficient but, the XAxis
does not get updated.??? Why.

Is there someway I can optimize this further?

Help Help....