Hello. I have a plot, which is updated on a timer. New points are taken from the database.
New points are added to the chart every 3 seconds and the plot is redrawn.
Code:
curv1->setAxes(xb,yl); myPlot->enableAxis(yl); curv1->attach(myPlot); connect (timerUpdPlot, SIGNAL(timeout()), SLOT(realTimePoints())); timerUpdPlot->start(3000); realTimePoints();
Curve is connected to zoomer
Code:
d_zoomer[0] = new Zoomer( xb, yl, myPlot->canvas());
Code:
void TrendTop::realTimePoints() { if (!db.open()) { CreateConnection(); } if (db.isOpen()) { query.exec("SELECT tm, val FROM currstamp where id = 1136"); if (query.next()) { osX = query.value(0).toUInt(); osY = query.value(1).toDouble(); } X++; vectX.append(X); vectY.append(osY); curv1->setSamples(vectX,vectY); myPlot->replot(); } }
Attachment 7367
But when I click zoom, plot itself is scaled to the very first point on the graph.
Attachment 7368
Although, I must first select the area that I want to scale.
Slot is invoked by pressing the zoom:
Code:
void TrendTop::enableZoomMode(bool on) { d_panner->setEnabled(on); d_zoomer[0]->setEnabled(on); d_zoomer[0]->zoom(0); d_zoomer1[0]->setEnabled(on); d_zoomer1[0]->zoom(0); }
What am I doing wrong?
