##// END OF EJS Templates
Remove index from QLineChartSeries API
Michal Klocek -
r348:c5af9c80b764
parent child
Show More
@@ -44,9 +44,9 public slots:
44
44
45 for (qreal i = 0, x = 0; x <= 2*PI; x+=m_step, i++) {
45 for (qreal i = 0, x = 0; x <= 2*PI; x+=m_step, i++) {
46 fluctuate = qrand() % 100;
46 fluctuate = qrand() % 100;
47 m_series1->set(i, x, fabs(sin(x)*fluctuate));
47 m_series1->replace(x, fabs(sin(x)*fluctuate));
48 fluctuate = qrand() % 100;
48 fluctuate = qrand() % 100;
49 m_series2->set(i, x, fabs(cos(x)*fluctuate));
49 m_series2->replace(x, fabs(cos(x)*fluctuate));
50 }
50 }
51
51
52 }
52 }
@@ -69,32 +69,29 QLineChartSeries::~QLineChartSeries()
69
69
70 /*!
70 /*!
71 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
71 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
72 Function returns index, which can be used to modify data.
73 */
72 */
74 int QLineChartSeries::add(qreal x,qreal y)
73 void QLineChartSeries::add(qreal x,qreal y)
75 {
74 {
76 m_x<<x;
75 m_x<<x;
77 m_y<<y;
76 m_y<<y;
78 return m_x.size()-1;
79 }
77 }
80
78
81 /*!
79 /*!
82 This is an overloaded function.
80 This is an overloaded function.
83 Adds data \a point to the series. Points are connected with lines on the chart.
81 Adds data \a point to the series. Points are connected with lines on the chart.
84 Function returns index, which can be used to modify data.
85 */
82 */
86 int QLineChartSeries::add(const QPointF& point)
83 void QLineChartSeries::add(const QPointF& point)
87 {
84 {
88 m_x<<point.x();
85 m_x<<point.x();
89 m_y<<point.y();
86 m_y<<point.y();
90 return m_x.size()-1;
91 }
87 }
92
88
93 /*!
89 /*!
94 Modifies data within \a index, sets new \a x and \a y values.
90 Modifies \a y value for given \a x a value.
95 */
91 */
96 void QLineChartSeries::set(int index,qreal x,qreal y)
92 void QLineChartSeries::replace(qreal x,qreal y)
97 {
93 {
94 int index = m_x.indexOf(x);
98 m_x[index]=x;
95 m_x[index]=x;
99 m_y[index]=y;
96 m_y[index]=y;
100 emit changed(index);
97 emit changed(index);
@@ -102,15 +99,31 void QLineChartSeries::set(int index,qreal x,qreal y)
102
99
103 /*!
100 /*!
104 This is an overloaded function.
101 This is an overloaded function.
105 Modifies data within \a index, sets new \a point value.
102 Replaces current y value of for given \a point x value with \a point y value.
106 */
103 */
107 void QLineChartSeries::set(int index,const QPointF& point)
104 void QLineChartSeries::replace(const QPointF& point)
108 {
105 {
106 int index = m_x.indexOf(point.x());
109 m_x[index]=point.x();
107 m_x[index]=point.x();
110 m_y[index]=point.y();
108 m_y[index]=point.y();
111 emit changed(index);
109 emit changed(index);
112 }
110 }
113
111
112 /*!
113 Removes current \a x and y value.
114 */
115 void QLineChartSeries::remove(qreal x)
116 {
117
118 }
119
120 /*!
121 Removes current \a point x value. Note \point y value is ignored.
122 */
123 void QLineChartSeries::remove(const QPointF& point)
124 {
125
126 }
114
127
115 /*!
128 /*!
116 Clears all the data.
129 Clears all the data.
@@ -18,10 +18,12 public:
18
18
19 public: // from QChartSeries
19 public: // from QChartSeries
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
21 int add(qreal x, qreal y);
21 void add(qreal x, qreal y);
22 int add(const QPointF& point);
22 void add(const QPointF& point);
23 void set(int index,qreal x,qreal y);
23 void replace(qreal x,qreal y);
24 void set(int index,const QPointF& point);
24 void replace(const QPointF& point);
25 void remove(qreal x);
26 void remove(const QPointF& point);
25 void clear();
27 void clear();
26
28
27 void setPen(const QPen& pen);
29 void setPen(const QPen& pen);
General Comments 0
You need to be logged in to leave comments. Login now