@@ -48,7 +48,7 void DataSource::update(QAbstractSeries *series) | |||
|
48 | 48 | if (m_index > m_data.count() - 1) |
|
49 | 49 | m_index = 0; |
|
50 | 50 | |
|
51 |
Q |
|
|
51 | QVector<QPointF> points = m_data.at(m_index); | |
|
52 | 52 | // Use replace instead of clear + append, it's optimized for performance |
|
53 | 53 | xySeries->replace(points); |
|
54 | 54 | } |
@@ -57,13 +57,14 void DataSource::update(QAbstractSeries *series) | |||
|
57 | 57 | void DataSource::generateData(int type, int rowCount, int colCount) |
|
58 | 58 | { |
|
59 | 59 | // Remove previous data |
|
60 |
foreach (Q |
|
|
60 | foreach (QVector<QPointF> row, m_data) | |
|
61 | 61 | row.clear(); |
|
62 | 62 | m_data.clear(); |
|
63 | 63 | |
|
64 | 64 | // Append the new data depending on the type |
|
65 | 65 | for (int i(0); i < rowCount; i++) { |
|
66 |
Q |
|
|
66 | QVector<QPointF> points; | |
|
67 | points.reserve(colCount); | |
|
67 | 68 | for (int j(0); j < colCount; j++) { |
|
68 | 69 | qreal x(0); |
|
69 | 70 | qreal y(0); |
@@ -42,7 +42,7 public slots: | |||
|
42 | 42 | |
|
43 | 43 | private: |
|
44 | 44 | QQuickView *m_appViewer; |
|
45 |
QList<Q |
|
|
45 | QList<QVector<QPointF> > m_data; | |
|
46 | 46 | int m_index; |
|
47 | 47 | }; |
|
48 | 48 |
@@ -494,13 +494,26 void QXYSeries::replace(int index, const QPointF &newPoint) | |||
|
494 | 494 | Replaces the current points with \a points. |
|
495 | 495 | \note This is much faster than replacing data points one by one, |
|
496 | 496 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
497 | when the points have been replaced. | |
|
497 | when the points have been replaced. However, note that using the overload that takes | |
|
498 | \c{QVector<QPointF>} as parameter is slightly faster than using this overload. | |
|
498 | 499 | \sa QXYSeries::pointsReplaced() |
|
499 | 500 | */ |
|
500 | 501 | void QXYSeries::replace(QList<QPointF> points) |
|
501 | 502 | { |
|
503 | replace(points.toVector()); | |
|
504 | } | |
|
505 | ||
|
506 | /*! | |
|
507 | Replaces the current points with \a points. | |
|
508 | \note This is much faster than replacing data points one by one, | |
|
509 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() | |
|
510 | when the points have been replaced. | |
|
511 | \sa QXYSeries::pointsReplaced() | |
|
512 | */ | |
|
513 | void QXYSeries::replace(QVector<QPointF> points) | |
|
514 | { | |
|
502 | 515 | Q_D(QXYSeries); |
|
503 |
d->m_points = points |
|
|
516 | d->m_points = points; | |
|
504 | 517 | emit pointsReplaced(); |
|
505 | 518 | } |
|
506 | 519 |
General Comments 0
You need to be logged in to leave comments.
Login now