Results 1 to 2 of 2

Thread: How to remove the x-axis rescale motion when a tick label appears in a realtime plot?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2014
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default How to remove the x-axis rescale motion when a tick label appears in a realtime plot?

    I have a real time plot where data is continuously added. When a tick label appears from the right of the x-axis (time) the axis is compressed a little and when the tick label disappears on the left side of the x-axis it is stretched a little. This affects my waveforms and also looks like lag.

    The only scaling I am doing in the initialization of the plot is:

    Qt Code:
    1. qwtDateScaleDraw = new QwtDateScaleDraw (Qt::OffsetFromUTC);
    2. qwtDateScaleDraw->setDateFormat(QwtDate::Second, "hh:mm:ss");
    3. qwtDateScaleDraw->setUtcOffset(QDateTime::currentMSecsSinceEpoch() / 1000);
    To copy to clipboard, switch view to plain text mode 

    And when new data is appended to the plot I rescale it to always have the previous 10 seconds of data visible by doing this:

    Qt Code:
    1. plot->setAxisScale(QwtPlot::xBottom, timeStamp - 10000, timeStamp, 1000);
    To copy to clipboard, switch view to plain text mode 

    (where timeStamp is QDateTime::currentMSecsSinceEpoch())

    I have been trying to get this to work for days now, but I can not figure it out =/

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to remove the x-axis rescale motion when a tick label appears in a realtime p

    This has to do with the rightmost tick label, that needs to have enough space.

    The most natural way to avoid this problem is to use the space below the left y axis. F.e. in the cpuplot example the tick labels are rotated and shifted, so that there is no overlapping part to the right. Another trick is simply to add an axis to the right ( having the same scale as the left one ).

    Next option is to overload QwtScaleDraw::tickLabel(), where you could decide to return QString::null when the most right tick is too close to the right border. "Too close" in this context means something in terms of 0.5 * QFontMetrics::width( label ) and the distance between the tick position and the border of the canvas in pixels.

    I also has a quick check, what needs to be done, when accepting, that the labels can be cut off. Would make sense for your use case, but I need more time on this and I'm afraid that won't be possible with Qwt 6.1 without patching some code.

    Uwe

Similar Threads

  1. Continuous x-axis qwt realtime plot
    By Phataas in forum Qwt
    Replies: 2
    Last Post: 4th February 2015, 21:53
  2. Axis Tick and Label !
    By huyhoangfool in forum Qwt
    Replies: 5
    Last Post: 29th July 2014, 12:20
  3. Remove space between axis and plot
    By Ozzy in forum Qwt
    Replies: 12
    Last Post: 16th January 2014, 13:48
  4. X axis tick label - font size
    By junhonguk in forum Qwt
    Replies: 5
    Last Post: 26th April 2012, 15:15
  5. Replies: 2
    Last Post: 29th September 2011, 13:10

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
  •  
Qt is a trademark of The Qt Company.