Data update frequency

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
dataqip
Posts: 14
Joined: Mon Aug 19, 2013 6:43 pm

Data update frequency

Post by dataqip » Mon Aug 19, 2013 7:19 pm

I'm currently evaluating the LightningChart Ultimate WPF SDK trial. I'm receiving data from a device in an event and using Dispatcher.Invoke() to update the chart, as shown in one of the examples. I happened to set the event to be fired as often as possible; this seemed to cause trouble for the chart. It would quickly lock-up the test application. I reduced the data event update frequency to something around 30fps and the application worked... better. It still seems to be a problem at higher rates (~1000 p/s showing 1000 points).

I was under the impression that the use of Begin/EndUpdate() along with SampleDataSeries and DropOldSeriesData would allow me to update the chart as fast as I could with data, letting it determine what data to display. This may have been presumptuous. Other than this being an observation, how should I best update the chart data?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Data update frequency

Post by ArctionPasi » Tue Aug 20, 2013 7:35 pm

Hi Dataqip,

that data rate is not any kind of problem or challenge to LightningChart. Make sure you are running the app without debugger attachment. So start the app with Ctrl+F5. Otherwise you will notice a serious performance penalty.

If you use a background thread, and in the thread loop you don't have any Sleep, you will notice that application is not responsive anymore, for sure. Always have Thread.Sleep(1) or more.

The optimal way to input scrolling data is instructed in Thread-fed Multi-channel data example:
Thread-fed multi-channel data example
Thread-fed multi-channel data example
Thread-fed-multi-ch-data.PNG (269.4 KiB) Viewed 16752 times
You may have looked at this example already. Please run this example and compare to your own implementation performance.
LightningChart Support Team, PT

dataqip
Posts: 14
Joined: Mon Aug 19, 2013 6:43 pm

Re: Data update frequency

Post by dataqip » Mon Aug 26, 2013 6:06 pm

OK. I figured out what was causing the problem. I assumed that between calling Begin/EndUpdate() and AddSamples(), the data array I was accessing would not be touched outside that section. Seems I was wrong. I have a data array which I'm filling with data and every so often plotting on the chart. I used locks to synchronize access to the array between the threads, but did not expect the control to access the data outside the previously mentioned calls.

Can you confirm whether this is true?

The example appears to always create new variables, so it doesn't run into this. I found this out when I created an intermediate array to which I copied the data inside my lock, then passed the intermediate to the chart control, effectively duplicating the example's creation of new variables each time.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Data update frequency

Post by ArctionPasi » Mon Aug 26, 2013 8:31 pm

You shouldn't modify the SamplesDouble or SamplesSingle array after you have assigned for the chart. In real-time measurement apps, it is best to start with sampleDataSeries.Clear(), and then just use AddSamples. LC handles the data adding into SamplesDouble array, and construction of rendering data. When ViewXY.DropOldSeriesData = True, it also internally removes old data points that are not shown the chart, periodically.
LightningChart Support Team, PT

dataqip
Posts: 14
Joined: Mon Aug 19, 2013 6:43 pm

Re: Data update frequency

Post by dataqip » Tue Aug 27, 2013 12:09 pm

I already do ViewXY.SampleDataSeries.Clear() and then add my own series (one for each Y-axis). When I have data, I do BeginUpdate(), series.AddSamples(), EndUpdate(). I was expecting the AddSamples() call to either use the provided array data internally or copy it, not claim ownership of the array. At least, that much was not clear anywhere. If AddSamples() is meant to bind the given array, it isn't clear from this usage, nor is it written in the documentation. But thank you for clarifying.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Data update frequency

Post by ArctionPasi » Tue Aug 27, 2013 12:29 pm

To prevent the confusion, I'm replying to this topic.

sampleDataSeries.AddSamples() copies the given data to end of internal array. It doesn't claim ownership of it.

But assigning series.SamplesDouble = yourArray, the chart does not copy the array, and claims ownership of it. After that, you shouldn't modify yourArray.

To clarify more, chart.ViewXY.SampleDataSeries.Clear() deletes all the series objects. That I didn't want to instruct here. Instead, sampleDataSeries.Clear() stands for chart.ViewXY.SampleDataSeries[0].Clear(), it will clear the samples from the series and should be used when starting the measurement if you haven't just created empty new series.
LightningChart Support Team, PT

dataqip
Posts: 14
Joined: Mon Aug 19, 2013 6:43 pm

Re: Data update frequency

Post by dataqip » Tue Aug 27, 2013 3:15 pm

OK, that makes more sense. I'm using chart.ViewXY.SampleDataSeries.Clear() to clear all series objects when setting up the chart. All my testing so far has been using sampleDataSeries.AddSamples() and not sampleDataSeries.SamplesDouble, yet I seem to be experiencing some issue.

Post Reply