@@ -48,7 +48,7 void DataSource::update(QAbstractSeries *series) | |||||
48 | if (m_index > m_data.count() - 1) |
|
48 | if (m_index > m_data.count() - 1) | |
49 | m_index = 0; |
|
49 | m_index = 0; | |
50 |
|
50 | |||
51 |
Q |
|
51 | QVector<QPointF> points = m_data.at(m_index); | |
52 | // Use replace instead of clear + append, it's optimized for performance |
|
52 | // Use replace instead of clear + append, it's optimized for performance | |
53 | xySeries->replace(points); |
|
53 | xySeries->replace(points); | |
54 | } |
|
54 | } | |
@@ -57,13 +57,14 void DataSource::update(QAbstractSeries *series) | |||||
57 | void DataSource::generateData(int type, int rowCount, int colCount) |
|
57 | void DataSource::generateData(int type, int rowCount, int colCount) | |
58 | { |
|
58 | { | |
59 | // Remove previous data |
|
59 | // Remove previous data | |
60 |
foreach (Q |
|
60 | foreach (QVector<QPointF> row, m_data) | |
61 | row.clear(); |
|
61 | row.clear(); | |
62 | m_data.clear(); |
|
62 | m_data.clear(); | |
63 |
|
63 | |||
64 | // Append the new data depending on the type |
|
64 | // Append the new data depending on the type | |
65 | for (int i(0); i < rowCount; i++) { |
|
65 | for (int i(0); i < rowCount; i++) { | |
66 |
Q |
|
66 | QVector<QPointF> points; | |
|
67 | points.reserve(colCount); | |||
67 | for (int j(0); j < colCount; j++) { |
|
68 | for (int j(0); j < colCount; j++) { | |
68 | qreal x(0); |
|
69 | qreal x(0); | |
69 | qreal y(0); |
|
70 | qreal y(0); |
@@ -42,7 +42,7 public slots: | |||||
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | QQuickView *m_appViewer; |
|
44 | QQuickView *m_appViewer; | |
45 |
QList<Q |
|
45 | QList<QVector<QPointF> > m_data; | |
46 | int m_index; |
|
46 | int m_index; | |
47 | }; |
|
47 | }; | |
48 |
|
48 |
@@ -494,13 +494,26 void QXYSeries::replace(int index, const QPointF &newPoint) | |||||
494 | Replaces the current points with \a points. |
|
494 | Replaces the current points with \a points. | |
495 | \note This is much faster than replacing data points one by one, |
|
495 | \note This is much faster than replacing data points one by one, | |
496 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
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 | \sa QXYSeries::pointsReplaced() |
|
499 | \sa QXYSeries::pointsReplaced() | |
499 | */ |
|
500 | */ | |
500 | void QXYSeries::replace(QList<QPointF> points) |
|
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 | Q_D(QXYSeries); |
|
515 | Q_D(QXYSeries); | |
503 |
d->m_points = points |
|
516 | d->m_points = points; | |
504 | emit pointsReplaced(); |
|
517 | emit pointsReplaced(); | |
505 | } |
|
518 | } | |
506 |
|
519 |
@@ -93,6 +93,7 public: | |||||
93 | QColor pointLabelsColor() const; |
|
93 | QColor pointLabelsColor() const; | |
94 |
|
94 | |||
95 | void replace(QList<QPointF> points); |
|
95 | void replace(QList<QPointF> points); | |
|
96 | void replace(QVector<QPointF> points); | |||
96 |
|
97 | |||
97 | Q_SIGNALS: |
|
98 | Q_SIGNALS: | |
98 | void clicked(const QPointF &point); |
|
99 | void clicked(const QPointF &point); |
General Comments 0
You need to be logged in to leave comments.
Login now