[chart] emit newDataRequest on scroll
This commit is contained in:
parent
cd2dfc1dac
commit
343e611fa4
12
chart.cpp
12
chart.cpp
@ -59,18 +59,8 @@ void Chart::XRangeChanged(qreal min, qreal max) {
|
||||
std::cerr << "XRangeChanged" << min << "\t"<< max << std::endl;
|
||||
if (series().at(0)->type() == QtCharts::QAbstractSeries::SeriesTypeLine) {
|
||||
QLineSeries *s = static_cast<QLineSeries *>(series().at(0));
|
||||
qreal xmax = s->at(s->count()-1).x();
|
||||
if (max > s->at(s->count()-1).x()) {
|
||||
QList<QPointF> buffer;
|
||||
|
||||
std::cerr << "new DATA!!!" << std::endl;
|
||||
double si = s->at(1).x() - s->at(0).x();
|
||||
qreal currentx = xmax;
|
||||
buffer.reserve(1000);
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
buffer.push_back({xmax + i * si, 0.0});
|
||||
}
|
||||
s->append(buffer);
|
||||
emit newDataRequest(this->entityId, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
chart.h
4
chart.h
@ -17,6 +17,7 @@ public:
|
||||
~Chart();
|
||||
|
||||
bool sceneEvent(QEvent *event);
|
||||
std::string entityId;
|
||||
|
||||
private:
|
||||
bool gestureEvent(QGestureEvent *event);
|
||||
@ -24,5 +25,8 @@ private:
|
||||
|
||||
public slots:
|
||||
void XRangeChanged(qreal min, qreal max);
|
||||
|
||||
signals:
|
||||
void newDataRequest(const std::string &entityId, qreal max);
|
||||
};
|
||||
#endif // CHART_H
|
||||
|
Loading…
Reference in New Issue
Block a user