# Thread: How implement real time history plot with data samples having varying timestamps?

1. Beginner
Join Date
Mar 2009
Posts
14
Thanked 2 Times in 2 Posts

## How implement real time history plot with data samples having varying timestamps?

Can anyone recommend an approach to plotting data with non-fixed elapsed time intervals?
Basically the X time values of each data sample are non-fixed, non-integral seconds, and will vary.
However, I want the X-axis time labels to remain in units of integral seconds (or perhaps minutes).

I am working on a real-time history plot based on the Qwt cpuplot example. While cpuplot works well it is implemented using a fixed 1.0 second time intervals. My time stamped data contains elapsed time stamp values in milliseconds rather than integral seconds and time bewteen samples can vary perhaps up to 1000 ms. How can I plot a data sample with a timestamp of 1.5 seconds and line up properly with an X-axis label displaying integral seconds?

Example of my time stamped data series:

1. 0 ms, 0.1 volts
2. 1350 ms, 0.22 volts
3. 2820 ms, 0.31 volts
4. 4120 ms, 0.47 volts
5. etc.

I attached a screenshot that may hep give you an idea of what I am seeking to accomplish.

Thanks in advance for any tips or direction,

-Ed
Last edited by esutton; 23rd October 2012 at 21:36.

2. Beginner
Join Date
Mar 2009
Posts
14
Thanked 2 Times in 2 Posts

## Re: How implement real time history plot with data samples having varying timestamps?

Solved. ( Sorry, bad arithmetic calculating elapsed time - it should have been working all along )

The cpuplot source was used pretty much as is, simply replacing the timer event handler with my own code that I called when I received the updated time-stamped data sample:

Qt Code:
`// Update X-axis time series labels for the amount of time that has passed since last update    double elapsedTimeIntervalSeconds = (structDataSample.timeStampMs - m_structDataSampleLast.timeStampMs) / 1000.0;    m_structDataSampleLast = structDataSample;    qDebug() << "Dbg: elapsedTimeIntervalSeconds = " << elapsedTimeIntervalSeconds << endl;    for ( int j = 0; j < HISTORY_BUFFER_LENGTH; j++ )    {        timeDataSeries[j] = timeDataSeries[j] + elapsedTimeIntervalSeconds;    }`
To copy to clipboard, switch view to plain text mode

3. Beginner
Join Date
Apr 2013
Posts
9
Qt products

## Re: How implement real time history plot with data samples having varying timestamps?

I'm also doing the same kind of application. I'm new to QWT and QT. Can u please upload the full code?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.