Autoscale axis with QwtPlotTradingCurve and set min x axis value
Hi all,
I am new to Qwt. I am able to draw a simple candlestick plot and add some surves for my own indicators. To do so, I have started from the example stockchart.
As in the example, I also have a zoom:
Code:
{
public:
{
setRubberBandPen
( QColor( Qt
::darkGreen ) );
}
protected:
{
const QDateTime dt
= QwtDate
::toDateTime( pos.
x() );
s += QwtDate::toString( QwtDate::toDateTime( pos.x() ), "MMM dd hh:mm ", QwtDate::FirstThursday );
text.setColor( Qt::white );
QColor c
= rubberBandPen
().
color();
text.
setBorderPen( QPen( c
) );
text.setBorderRadius( 6 );
c.setAlpha( 170 );
text.setBackgroundBrush( c );
return text;
}
};
And in my Plot constructor:
Code:
PlotWidget
::PlotWidget(QWidget *parent
):{
// LeftButton for the zooming
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
Zoomer* zoomer = new Zoomer( canvas() );
zoomer
->setMousePattern
( QwtEventPattern::MouseSelect2, Qt
::RightButton, Qt
::ControlModifier );
// MidButton for the panning
panner->setMouseButton( Qt::MidButton );
_scaleDraw = new DateScaleDraw( Qt::UTC );
_scaleEngine = new QwtDateScaleEngine( Qt::UTC );
setAxisScaleDraw
( QwtPlot::xBottom, _scaleDraw
);
setAxisScaleEngine
( QwtPlot::xBottom, _scaleEngine
);
setAxisLabelRotation
( QwtPlot::xBottom,
-50.0 );
setAxisLabelAlignment
( QwtPlot::xBottom, Qt
::AlignLeft | Qt
::AlignBottom );
}
OK. Nothing new ... The problems are with the zoom.
* If I press the home key, I go back to 1 january 1970 (begin of UTC time?). How can I say that the first date in my plot is for instance 1st april 2014 and disallow the user to go before?
* When I select a zoom region, the values on the y axis are not scaled according to the content, and thus, the plot display "flat" curves. How can I fix this? The same also applies to Ctrl+Right clic.
Hope you could help
Best regards
Re: Autoscale axis with QwtPlotTradingCurve and set min x axis value
Problem solved. Had to call
Code:
_zoomer->setZoomBase();
and everything works like a charm.