##// 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 20 // Chart takes ownership
21 21 chartView->addSeries(scatter);
22 22 //! [1]
23 // scatter->replace(0, QPointF(0.75, 5.0));
23 24
24 25 // And more
25 26 //! [3]
26 27 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
27 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 32 // - more data with random component
31 33 scatter = new QScatterSeries();
32 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
148 at \a pointIndex does not exist on the series.
147 Replaces the point at \a index with \a newPoint. Returns true if \a index is a valid position
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()) {
153 d->m_data.removeAt(pointIndex);
152 if (index >= 0 && index < d->m_data.count()) {
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 168 emit changed();
155 169 return true;
156 170 }
@@ -40,7 +40,8 public:
40 40 QScatterSeries& operator << (const QPointF &value);
41 41 QScatterSeries& operator << (QList<QPointF> points);
42 42 QList<QPointF> data();
43 bool removeAt(int pointIndex);
43 bool replace(int index, QPointF newPoint);
44 bool removeAt(int index);
44 45 int removeAll(QPointF point);
45 46 void clear();
46 47 int closestPoint(QPointF coordinate);
General Comments 0
You need to be logged in to leave comments. Login now