Results 1 to 13 of 13

Thread: Time in x - axis

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Default Re: Time in x - axis

    Thank you very much desantossierra!,

    this helps really a lot!

    for my understanding i have to map all the x-values, right?

    that means for example:
    value1: y = 5, x=08:00 clock,
    value2: y = 10, x = 08:25...
    value3: y= 3, x = 9:45...

    so the first value for x is 0800, -> x = 1 ( if 8:00 is the startvalue for the x-axis.)
    2nd value x 08:25 -> x = 1,41 - for correct display ?
    3rd value x 9:45, -> x = 2,75 - for correct display ?

    TIA
    Faramia

  2. #2
    Join Date
    Jan 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 3 Times in 3 Posts

    Default Re: Time in x - axis

    mmm...

    why x=1,41?

    for example, if x is the double value of the label method then you could use something like this

    int hour = (floor(x) + initHour ) % 24 ;
    int minute = 60*(x - floor(x));
    return QwtText(QString('%1:%2').arg(hour).arg(minute));

  3. The following user says thank you to desantossierra for this useful post:

    Faramia (6th February 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Default Re: Time in x - axis

    Thank you again desantossierra,

    i will try ur solution.

    i thought and tested it, that the x-axis values starts every time with 1. (not the label, the values in the plot.... - for example, if i start wiht 8:00 to 15:00 (x axis labels...) and if i want to display a x value with y = 5 and x = 8:00, i have to map x to 1 to set the correct display in the plot...
    But perhaps i am wrong so i will try your solution.

    Thank again and again!

    Sorry for my bad english

    Faramia

  5. #4
    Join Date
    Jan 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 3 Times in 3 Posts

    Default Re: Time in x - axis

    don't worry for your english, my english is worse

    tell me if works or not

  6. #5
    Join Date
    Jan 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4

    Default Re: Time in x - axis

    it works ty!

  7. #6
    Join Date
    Jan 2012
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: Time in x - axis

    Hello, I also have a question about the time axis X.
    Value for the X axis, I get in the loop from the database in the format of Unix time like 1328612875.
    From the example cpuplot, write the following:
    Qt Code:
    1. class TimeScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. TimeScaleDraw(const QTime &base):
    5. baseTime(base)
    6. {
    7. }
    8. virtual QwtText label(double v) const
    9. {
    10.  
    11. QTime upTime = baseTime.addSecs((int)v);
    12. return upTime.toString();
    13. }
    14. private:
    15. QTime baseTime;
    16. };
    17.  
    18.  
    19. QTime TrendTop::upTime() const
    20. {
    21. QTime t;
    22. t=QTime::currentTime();
    23. return t;
    24. }
    To copy to clipboard, switch view to plain text mode 

    But time is displayed on the X axis does not correspond to reality.
    Can you please tell what I need to fix?

  8. #7
    Join Date
    Jan 2012
    Posts
    17
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 3 Times in 3 Posts

    Default Re: Time in x - axis

    The time correspond with the creation time plus a X value.

    what do you want to do exactly?

    Maybe you need a QList<QTime> to save the times you want to represent in x-axis,
    but I don't know what you are doing

Similar Threads

  1. Replies: 1
    Last Post: 2nd August 2011, 18:01
  2. Replies: 9
    Last Post: 3rd May 2011, 21:21
  3. Time/Date Axis
    By sigger in forum Qwt
    Replies: 12
    Last Post: 1st May 2011, 09:55
  4. Replies: 2
    Last Post: 8th February 2011, 14:53
  5. Replies: 0
    Last Post: 9th August 2010, 10:46

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.