Closed taibai123abc closed 1 month ago
I'm not sure what you try to achieve?
Bind a scrollbar to a plot, that displays a section from a graph with pre-known maximalextent?
I think you could achieve such a thing, using the signal JKQTPlotter::zoomChangedLocally() ... that signal is emitted, whenever the zoom changes and provides the currently displayed data-range in x- and y-direction. The you could calculate the data required for the QScrollBar ...
Does that help?
Yes, and I have achieved it like this slot:
void FormWithJKQTPlotter::onActionViewChanged(int value)
{
JKQTPDatastore* ds = ui->plot->getDatastore();
//dateAndTime and squeezeData are the whole data, partXData and partYData
//are the data which are shown on the plot.
QVector<double> partXData = dateAndTime.mid(value, ui->numSpinBox->value());
QVector<double> partYData = squeezeData.mid(value, ui->numSpinBox->value());
ds->clear();
size_t colDate = ds->addCopiedColumn(partXData, "date");
size_t colSq = ds->addCopiedColumn(partYData, "squeeze");
graph->setXColumn(colDate);
graph->setYColumn(colSq);
ui->plot->getXAxis()->setTickLabelType(JKQTPCALTdatetime);
ui->plot->getXAxis()->setAxisLabel("Time and Date");
ui->plot->getXAxis()->setTickDateTimeFormat("yyyy/MM/dd HH:mm");
ui->plot->getXAxis()->setTickLabelFontSize(5);
ui->plot->getXAxis()->setTickSpacing(3);
ui->plot->zoomToFit();
ui->plot->show();
ui->plot->resize(600, 300);
}
But I faced a problem that when I drag the graph horizontally, the left and right sides of the graph cannot be refreshed. The effect is shown below: The right side graph cannot be complemented while i drag the plot. Though the jkqtplotter has many useful signals such as plotMouseMove, plotMouseWheelOperated and so on, but i cannot find a suitable signals for the drag "event".
Bind a scrollbar to a plot, that displays a section from a graph with pre-known maximalextent?
Please have a look at the recently added example https://github.com/jkriege2/JKQtPlotter/tree/master/examples/ui_bind_scrollbar , which shows how to do what you requested ... unless I missunderstood your request ;-)
Thanks, I have changed the problem via the signal "zoomChanged locally".
JKQTPlotter cannot support QScrollBar originally. I have released a plot with QScrollBar. But while I drag the plot, i cannot update the graph. Can you add a signal which can be emited after the plot has been drag?