Not 100% sure why you are struggling with this, but o.k. let me elaborate one possible implementation.
Assuming, that you always have 100 rows of data. Every second you receive a new row, that is added on top, while the most bottom row is thrown away.
Then you can manually set up an inverted scale turning autoscaling off:
plot
->setAxis
( QwtPlot::yLeft,
100,
0 );
// not 0, 100 !
plot->setAxis( QwtPlot::yLeft, 100, 0 );// not 0, 100 !
To copy to clipboard, switch view to plain text mode
The y-interval of your data also always stays at 0-100.
Finally you have:
{
public:
void increment()
{
m_offset++;
invalidateCache();
}
QwtText label
(double value
) const override
{
}
private:
double m_offset = 0;
};
plot->setAxisScaleDraw( new YourScaleDraw() );
class YourScaleDraw : public QwtScaleDraw
{
public:
void increment()
{
m_offset++;
invalidateCache();
}
QwtText label (double value ) const override
{
return QwtScaleDraw::label( value - m_offset );
}
private:
double m_offset = 0;
};
plot->setAxisScaleDraw( new YourScaleDraw() );
To copy to clipboard, switch view to plain text mode
Now whenever a new row arrives you simply shift your data down by one row and add the new row add the top. Next you increment the scale draw offset and call replot.
You probably don't want to have labels like -11, but you are free to return whatever makes sense in your case from YourScaleDraw::label.
Of course there are other ways to implement the effect where you don't have a mismatch between the label and the actual value, but maybe try this first to get things started.
Uwe
Bookmarks