Results 1 to 2 of 2

Thread: How to adjust my yData according to my Time scale

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default How to adjust my yData according to my Time scale

    I want to draw a dummy graph with time values on X-Axis with a increment of 15 seconds. On Y Axis, I'm passing data. I want the graph to set Y values to match x-values. But I'm unable to do so. I've copied the code in CpuPlot. But I couldn't make it work for my requirement.

    curve = new QwtPlotCurve();
    curve->setStyle(QwtPlotCurve::Lines);
    curve->setCurveAttribute(QwtPlotCurve::Fitted, true);
    curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);


    const double a[] = {12.30, 12.31, 12.32, 12.33, 12.34, 12.35, 12.36, 12.37, 12.38, 12.39, 12.4};
    const double b[] = {880, 851, 822, 834, 845, 838, 810, 853, 814, 809, 800};

    curve->setSamples(a, b, 11);
    curve->attach(oParamGraph);

    oParamGraph->setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw(cpuStat.upTime()));
    oParamGraph->setAxisScale(QwtPlot::xBottom, 0, 165, 15);
    With the above code, I'm getting the graph like this.
    Graph1.jpg

    Instead I want my graph to be like this. Which is aligned with respect to the const double b[] values like shown below
    Graph2.jpg

    How do I do?

    Thank you.
    Last edited by rawfool; 30th April 2012 at 11:57.

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

    Default Re: How to adjust my yData according to my Time scale

    The code in the cpuplot example interprets the x values as seconds since some start date. The minimum and the maximum in your array have a difference of 0.1s what obviously results in a vertical line, when displayed on a scale with a range of 155s.

    Uwe

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

    rawfool (30th April 2012)

Similar Threads

  1. QwtScaleEngine Time scale engine
    By med_1309 in forum Qwt
    Replies: 1
    Last Post: 25th August 2010, 18:54
  2. Replies: 4
    Last Post: 11th July 2010, 09:47
  3. Replies: 1
    Last Post: 21st April 2010, 02:54
  4. Time in a xBotton scale
    By qtprgrmr in forum Qwt
    Replies: 2
    Last Post: 12th April 2010, 13:53
  5. Replies: 0
    Last Post: 6th March 2009, 08:19

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.