Results 1 to 3 of 3

Thread: Suggested way to implement a time-series plot

  1. #1
    Join Date
    Oct 2017
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Suggested way to implement a time-series plot

    Hello,
    I need to implement a time-series plot (i.e. a plot where every second one new sample is added to a curve).
    When the curves contains more than a given number of samples (as an example 100), the x-scale is set so that only the most recent 100 samples are shown.

    I did this calling
    Qt Code:
    1. QwtPlotCurve::setSamples()
    To copy to clipboard, switch view to plain text mode 
    after I get every new sample, and setting the whole time-history.
    I set the x-scale when it's necessary.

    But I wonder if there is a better way (maybe appending a new sample to an existing curve).

    Thanks in advance

  2. #2
    Join Date
    Oct 2017
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Suggested way to implement a time-series plot

    Sorry for pushing,
    but can someone share ideas or link to documentation on how to implement a time-series plot?

    Every idea is welcome.
    Thanks in advance

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Suggested way to implement a time-series plot

    It sounds like you are confusing the map and the earth it represents. You should be storing your time series data in a separate data structure, not the curve itself. When each new point comes in, you give the curve only the last 100 points to plot and set the x axis range accordingly.

    If you don't want your data structure to save points for infinity, you can implement the data structure as a fixed-length linked list, and append new points to the head while removing old points from the tail end. To make copying the last 100 points quick without having to travel the whole list, save the pointer to the list position where the copy starts, and as each new point comes in, add it to the head, move the pointer forward one item in the list, then copy the points from there forward into the curve and update the plot.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. MATLAB Time Series function equivalent in Qt
    By Udayagiri Rithwik in forum Newbie
    Replies: 1
    Last Post: 3rd July 2018, 23:29
  2. QWT and time series
    By Neekeetos in forum Qwt
    Replies: 5
    Last Post: 2nd July 2018, 07:03
  3. QML ChartView Time Series
    By scgrant327 in forum Qt Programming
    Replies: 0
    Last Post: 18th August 2016, 16:02
  4. Replies: 2
    Last Post: 28th January 2014, 10:02
  5. Replies: 2
    Last Post: 5th April 2013, 05:58

Bookmarks

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.