##// END OF EJS Templates
Replace to QScatterSeries
Tero Ahola -
r395:9f537617b108
parent child
Show More
@@ -20,13 +20,15 int main(int argc, char *argv[])
20 // Chart takes ownership
20 // Chart takes ownership
21 chartView->addSeries(scatter);
21 chartView->addSeries(scatter);
22 //! [1]
22 //! [1]
23 // scatter->replace(0, QPointF(0.75, 5.0));
23
24
24 // And more
25 // And more
25 //! [3]
26 //! [3]
26 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
27 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
27 //! [3]
28 //! [3]
28
29
29 // Add another scatter series (re-use the previous pointer)
30 // Add another scatter series (re-use the previous pointer because the code used as snippets
31 // in the docs)
30 // - more data with random component
32 // - more data with random component
31 scatter = new QScatterSeries();
33 scatter = new QScatterSeries();
32 for (qreal i(0.0); i < 20; i += 0.15) {
34 for (qreal i(0.0); i < 20; i += 0.15) {
@@ -144,13 +144,27 QList<QPointF> QScatterSeries::data()
144 }
144 }
145
145
146 /*!
146 /*!
147 Remove the data point at \a pointIndex. Returns true if a point was removed, false if the point
147 Replaces the point at \a index with \a newPoint. Returns true if \a index is a valid position
148 at \a pointIndex does not exist on the series.
148 in the series data, false otherwise.
149 */
149 */
150 bool QScatterSeries::removeAt(int pointIndex)
150 bool QScatterSeries::replace(int index, QPointF newPoint)
151 {
151 {
152 if (pointIndex >=0 && pointIndex < d->m_data.count()) {
152 if (index >= 0 && index < d->m_data.count()) {
153 d->m_data.removeAt(pointIndex);
153 d->m_data.replace(index, newPoint);
154 emit changed();
155 return true;
156 }
157 return false;
158 }
159
160 /*!
161 Remove the data point at \a index. Returns true if a point was removed, false if the point
162 at \a index does not exist on the series.
163 */
164 bool QScatterSeries::removeAt(int index)
165 {
166 if (index >=0 && index < d->m_data.count()) {
167 d->m_data.removeAt(index);
154 emit changed();
168 emit changed();
155 return true;
169 return true;
156 }
170 }
@@ -40,7 +40,8 public:
40 QScatterSeries& operator << (const QPointF &value);
40 QScatterSeries& operator << (const QPointF &value);
41 QScatterSeries& operator << (QList<QPointF> points);
41 QScatterSeries& operator << (QList<QPointF> points);
42 QList<QPointF> data();
42 QList<QPointF> data();
43 bool removeAt(int pointIndex);
43 bool replace(int index, QPointF newPoint);
44 bool removeAt(int index);
44 int removeAll(QPointF point);
45 int removeAll(QPointF point);
45 void clear();
46 void clear();
46 int closestPoint(QPointF coordinate);
47 int closestPoint(QPointF coordinate);
General Comments 0
You need to be logged in to leave comments. Login now