Results 1 to 20 of 20

Thread: Gantt charts with QWT ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Gantt charts with QWT ?

    Has anyone ever tried to create a Gannt like chart with QWT ?

    See also this thread: http://www.qtcentre.org/threads/3175...tt-Chart-in-Qt

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

    Default Re: Gantt charts with QWT ?

    A QwtPlotIntervalCurve with a symbol in QwtIntervalSymbol::Box style should be pretty close to the screenshot of your linked thread. But I guess you want to display more than the interval bars only.

    Uwe

  3. #3

    Default Re: Gantt charts with QWT ?

    Hi Uwe,

    Thanks for your reply.
    I will give your idea a try.

    The bars are fine. If i can show some 'name' of the tasks that was running on the Y-axis that would be great.

    The input of my chart would be (still guessing, dont have anythng yet):

    <task>
    <id>waiting for trigger</id>
    <starttime> 123123123123 </starttime>
    <stoptime> 123123123223 </stoptime>
    </task>

    I can browse the file, and collect all events of the same id, and display them on the same curve, if i can then display the "waiting for trigger" on the y asis label, were good.

    Thanks, sorry for the extra info.

  4. #4

    Default Re: Gantt charts with QWT ?

    Hi Uwe,

    I've tried to follow your lead:

    QVector<QwtIntervalSample> samples;
    samples.append( QwtIntervalSample( 10, 8, 12 ) );
    samples.append( QwtIntervalSample( 2, 3, 7 ) );
    samples.append( QwtIntervalSample( 18, 17, 20 ) );

    QwtIntervalSymbol symbol( QwtIntervalSymbol::Box );
    QwtPlot *myPlot = new QwtPlot( NULL );

    QwtPlotIntervalCurve *curve1 = new QwtPlotIntervalCurve("Curve 1");
    curve1->setSymbol( &symbol );
    curve1->setSamples( samples );
    curve1->attach( myPlot );
    curve1->setStyle( QwtPlotIntervalCurve::NoCurve );


    for example : samples.append( QwtIntervalSample( 10, 8, 12 ) );
    draws a box on X position 10, ranging from Y value 8 to 12. (e.g. a vertical box).
    The interval is defined as [y1-y2]=f(x).

    Any way to swap the x and y axis ?
    Better idea ?

    Thanks for any help.

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

    Default Re: Gantt charts with QWT ?

    Quote Originally Posted by thejester View Post
    Any way to swap the x and y axis ?
    Qt Code:
    1. curve1->setOrientation( Qt::Horizontal );
    To copy to clipboard, switch view to plain text mode 

    Uwe

  6. #6

    Default Re: Gantt charts with QWT ?

    Thanks, got it up and running !

    Uwe, you're the best !

  7. #7

    Default Re: Gantt charts with QWT ?

    Uwe,

    Couple more questions...

    1) i have created a TaskNamesDraw derived from QwtScaleDraw that draws the names on the y-axis, to get the same as in the other gannt thread. This is working as expected, except that only major ticks are drawn. For example if Yvalues range from 0 to 10, then only 0, 2, 4 etc. are drawn, but not the 1, 3, etc. How can i make it draw ALL labels ?

    2) In stuff we talked about earlier we had the samples we provided to the plot defined as :
    samples.append( QwtIntervalSample( 10, 8, 12 ) );
    samples.append( QwtIntervalSample( 2, 3, 7 ) );
    samples.append( QwtIntervalSample( 18, 17, 20 ) );

    if i change this to :

    samples.append( QwtIntervalSample( 10, 800000, 800100 ) );
    samples.append( QwtIntervalSample( 2, 800400, 800500 ) );
    samples.append( QwtIntervalSample( 18, 800600, 800700 ) );

    i get 3 beautiful bars on the initial draw. If i zoom it it works perfectly;
    When i zoom out (all the way to empty zoom stack), then the x-axis values are
    somehow reset to 0...1000 and i loose my bars in the plot.
    Is there some way to 'define' the overview x and y ranges ?

    3) when zooming in, i only want x-axis zoom, not y-axis zoom.
    How can i enforce this ?

    Hope you can point me in the right directions that would be great.

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

    Default Re: Gantt charts with QWT ?

    This is working as expected, except that only major ticks are drawn.
    No all ticks are painted, but maybe you didn't define the ticks you are missing.

    i get 3 beautiful bars on the initial draw. If i zoom it it works perfectly;
    When i zoom out (all the way to empty zoom stack), then the x-axis values are
    somehow reset to 0...1000 and i loose my bars in the plot.
    This is a question you find many, many times answered in this forum:

    The zoomer is initialized with the current state of the scales and 0.0->1000.0 is the default setting. Obviously you are changing the scales later and forgot to reinitialize the zoomer: See http://qwt.sourceforge.net/class_qwt...58c52f0b5c7bc2

    when zooming in, i only want x-axis zoom, not y-axis zoom.
    How can i enforce this ?
    If you need one y axis only you can simply assign the other one to the zoomer: http://qwt.sourceforge.net/class_qwt...133a5cb6652e3d

    If not you have to reimplement QwtPlotZoomer::zoom( const QRectF & ), where you adjust the y coordinates and then call the base class.

    Uwe

  9. #9

    Default Re: Gantt charts with QWT ?

    With the first question, i meant that the derived virtual QwtText label(double v) const of the special QwtScaleDraw is only called for values 0, 2, 4 etc. but not for 1, 3, etc. What do you mean by "but maybe you didn't define the ticks you are missing" ?

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

    Default Re: Gantt charts with QWT ?

    When you are talking about the tick labels - not the ticks: yes, the labels are for major ticks only.

    Uwe

  11. #11

    Default Re: Gantt charts with QWT ?

    ok, thanks.

    Got the fixed y-axis zoom, independent of the x-axis zoom working, indeed by reimplementing the QwtPlotZoomer::zoom.
    Also got the init of the zoomBase working.

    The first problem is still giving me problems.
    When i do : setAxisScale( QwtPlot::yLeft, 0, max, 1 ); and have the max set to the number of horizontal gannt lines it works.
    But after a zoom in and out, they are gone again, and i end up with the labels on the major ticks.

    How can i fix this ? connect the zoomed signal to a slot in the plot and call setAxisScale( QwtPlot::yLeft, 0, max, 1 ); again ?

Similar Threads

  1. Replies: 21
    Last Post: 8th December 2011, 03:18
  2. Charts in Qt!!
    By rachana in forum Qt Programming
    Replies: 3
    Last Post: 6th May 2011, 07:10
  3. Mouse Interactive Gantt Chart in Qt
    By iuha in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2011, 10:00
  4. Help with Bar charts
    By romeo in forum Qwt
    Replies: 0
    Last Post: 30th June 2010, 17:58
  5. MVC charts for Qt4
    By wysota in forum Qt-based Software
    Replies: 8
    Last Post: 28th September 2006, 17:06

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.