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
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
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
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.
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.
Qt Code:
curve1->setOrientation( Qt::Horizontal );To copy to clipboard, switch view to plain text mode
Uwe
Thanks, got it up and running !
Uwe, you're the best !
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.
No all ticks are painted, but maybe you didn't define the ticks you are missing.This is working as expected, except that only major ticks are drawn.
This is a question you find many, many times answered in this forum: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.
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
If you need one y axis only you can simply assign the other one to the zoomer: http://qwt.sourceforge.net/class_qwt...133a5cb6652e3dwhen zooming in, i only want x-axis zoom, not y-axis zoom.
How can i enforce this ?
If not you have to reimplement QwtPlotZoomer::zoom( const QRectF & ), where you adjust the y coordinates and then call the base class.
Uwe
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" ?
When you are talking about the tick labels - not the ticks: yes, the labels are for major ticks only.
Uwe
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 ?
Bookmarks