@@ -1,195 +1,195 | |||||
1 | #include "qlineseries.h" |
|
1 | #include "qlineseries.h" | |
2 |
|
2 | |||
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
4 |
|
4 | |||
5 | /*! |
|
5 | /*! | |
6 |
\class QLine |
|
6 | \class QLineSeries | |
7 |
\brief The QLine |
|
7 | \brief The QLineSeries class is used for making line charts. | |
8 |
|
8 | |||
9 | \mainclass |
|
9 | \mainclass | |
10 |
|
10 | |||
11 | A line chart is used to show information as a series of data points |
|
11 | A line chart is used to show information as a series of data points | |
12 | connected by straight lines. |
|
12 | connected by straight lines. | |
13 |
|
13 | |||
14 | \image linechart.png |
|
14 | \image linechart.png | |
15 |
|
15 | |||
16 |
To create line charts, users need to first QLine |
|
16 | To create line charts, users need to first QLineSeries object. | |
17 |
|
17 | |||
18 | \snippet ../example/linechart/main.cpp 1 |
|
18 | \snippet ../example/linechart/main.cpp 1 | |
19 |
|
19 | |||
20 | Populate with the data |
|
20 | Populate with the data | |
21 |
|
21 | |||
22 | \snippet ../example/linechart/main.cpp 2 |
|
22 | \snippet ../example/linechart/main.cpp 2 | |
23 |
|
23 | |||
24 | Add created series objects to QChartView or QChart instance. |
|
24 | Add created series objects to QChartView or QChart instance. | |
25 |
|
25 | |||
26 | \snippet ../example/linechart/main.cpp 3 |
|
26 | \snippet ../example/linechart/main.cpp 3 | |
27 |
|
27 | |||
28 | */ |
|
28 | */ | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 |
\fn virtual QChartSeriesType QLine |
|
31 | \fn virtual QChartSeriesType QLineSeries::type() const | |
32 | \brief Returns type of series. |
|
32 | \brief Returns type of series. | |
33 | \sa QChartSeries, QChartSeriesType |
|
33 | \sa QChartSeries, QChartSeriesType | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 |
\fn QPen QLine |
|
37 | \fn QPen QLineSeries::pen() const | |
38 | \brief Returns the pen used to draw line for this series. |
|
38 | \brief Returns the pen used to draw line for this series. | |
39 | \sa setPen() |
|
39 | \sa setPen() | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 |
\fn bool QLine |
|
43 | \fn bool QLineSeries::isPointsVisible() const | |
44 | \brief Returns if the points are drawn for this series. |
|
44 | \brief Returns if the points are drawn for this series. | |
45 | \sa setPointsVisible() |
|
45 | \sa setPointsVisible() | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 |
\fn void QLine |
|
50 | \fn void QLineSeries::changed(int index) | |
51 | \brief \internal \a index |
|
51 | \brief \internal \a index | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | Constructs empty series object which is a child of \a parent. |
|
55 | Constructs empty series object which is a child of \a parent. | |
56 | When series object is added to QChartView or QChart instance ownerships is transfered. |
|
56 | When series object is added to QChartView or QChart instance ownerships is transfered. | |
57 | */ |
|
57 | */ | |
58 | QLineSeries::QLineSeries(QObject* parent):QChartSeries(parent), |
|
58 | QLineSeries::QLineSeries(QObject* parent):QChartSeries(parent), | |
59 | m_pointsVisible(false) |
|
59 | m_pointsVisible(false) | |
60 | { |
|
60 | { | |
61 | } |
|
61 | } | |
62 | /*! |
|
62 | /*! | |
63 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
63 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
64 | and are deleted when mentioned object are destroyed. |
|
64 | and are deleted when mentioned object are destroyed. | |
65 | */ |
|
65 | */ | |
66 | QLineSeries::~QLineSeries() |
|
66 | QLineSeries::~QLineSeries() | |
67 | { |
|
67 | { | |
68 | } |
|
68 | } | |
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 | */ |
|
72 | */ | |
73 | void QLineSeries::add(qreal x,qreal y) |
|
73 | void QLineSeries::add(qreal x,qreal y) | |
74 | { |
|
74 | { | |
75 | m_x<<x; |
|
75 | m_x<<x; | |
76 | m_y<<y; |
|
76 | m_y<<y; | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | This is an overloaded function. |
|
80 | This is an overloaded function. | |
81 | 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. | |
82 | */ |
|
82 | */ | |
83 | void QLineSeries::add(const QPointF& point) |
|
83 | void QLineSeries::add(const QPointF& point) | |
84 | { |
|
84 | { | |
85 | m_x<<point.x(); |
|
85 | m_x<<point.x(); | |
86 | m_y<<point.y(); |
|
86 | m_y<<point.y(); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | Modifies \a y value for given \a x a value. |
|
90 | Modifies \a y value for given \a x a value. | |
91 | */ |
|
91 | */ | |
92 | void QLineSeries::replace(qreal x,qreal y) |
|
92 | void QLineSeries::replace(qreal x,qreal y) | |
93 | { |
|
93 | { | |
94 | int index = m_x.indexOf(x); |
|
94 | int index = m_x.indexOf(x); | |
95 | m_x[index]=x; |
|
95 | m_x[index]=x; | |
96 | m_y[index]=y; |
|
96 | m_y[index]=y; | |
97 | emit changed(index); |
|
97 | emit changed(index); | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | This is an overloaded function. |
|
101 | This is an overloaded function. | |
102 | Replaces current y value of for given \a point x value with \a point y value. |
|
102 | Replaces current y value of for given \a point x value with \a point y value. | |
103 | */ |
|
103 | */ | |
104 | void QLineSeries::replace(const QPointF& point) |
|
104 | void QLineSeries::replace(const QPointF& point) | |
105 | { |
|
105 | { | |
106 | int index = m_x.indexOf(point.x()); |
|
106 | int index = m_x.indexOf(point.x()); | |
107 | m_x[index]=point.x(); |
|
107 | m_x[index]=point.x(); | |
108 | m_y[index]=point.y(); |
|
108 | m_y[index]=point.y(); | |
109 | emit changed(index); |
|
109 | emit changed(index); | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | /*! |
|
112 | /*! | |
113 | Removes current \a x and y value. |
|
113 | Removes current \a x and y value. | |
114 | */ |
|
114 | */ | |
115 | void QLineSeries::remove(qreal x) |
|
115 | void QLineSeries::remove(qreal x) | |
116 | { |
|
116 | { | |
117 |
|
117 | |||
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Removes current \a point x value. Note \point y value is ignored. |
|
121 | Removes current \a point x value. Note \point y value is ignored. | |
122 | */ |
|
122 | */ | |
123 | void QLineSeries::remove(const QPointF& point) |
|
123 | void QLineSeries::remove(const QPointF& point) | |
124 | { |
|
124 | { | |
125 |
|
125 | |||
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | /*! |
|
128 | /*! | |
129 | Clears all the data. |
|
129 | Clears all the data. | |
130 | */ |
|
130 | */ | |
131 | void QLineSeries::clear() |
|
131 | void QLineSeries::clear() | |
132 | { |
|
132 | { | |
133 | m_x.clear(); |
|
133 | m_x.clear(); | |
134 | m_y.clear(); |
|
134 | m_y.clear(); | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | /*! |
|
137 | /*! | |
138 | \internal \a pos |
|
138 | \internal \a pos | |
139 | */ |
|
139 | */ | |
140 | qreal QLineSeries::x(int pos) const |
|
140 | qreal QLineSeries::x(int pos) const | |
141 | { |
|
141 | { | |
142 | return m_x.at(pos); |
|
142 | return m_x.at(pos); | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | /*! |
|
145 | /*! | |
146 | \internal \a pos |
|
146 | \internal \a pos | |
147 | */ |
|
147 | */ | |
148 | qreal QLineSeries::y(int pos) const |
|
148 | qreal QLineSeries::y(int pos) const | |
149 | { |
|
149 | { | |
150 | return m_y.at(pos); |
|
150 | return m_y.at(pos); | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | /*! |
|
153 | /*! | |
154 | Returns number of data points within series. |
|
154 | Returns number of data points within series. | |
155 | */ |
|
155 | */ | |
156 | int QLineSeries::count() const |
|
156 | int QLineSeries::count() const | |
157 | { |
|
157 | { | |
158 | Q_ASSERT(m_x.size() == m_y.size()); |
|
158 | Q_ASSERT(m_x.size() == m_y.size()); | |
159 |
|
159 | |||
160 | return m_x.size(); |
|
160 | return m_x.size(); | |
161 |
|
161 | |||
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Sets \a pen used for drawing given series.. |
|
165 | Sets \a pen used for drawing given series.. | |
166 | */ |
|
166 | */ | |
167 | void QLineSeries::setPen(const QPen& pen) |
|
167 | void QLineSeries::setPen(const QPen& pen) | |
168 | { |
|
168 | { | |
169 | m_pen=pen; |
|
169 | m_pen=pen; | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | Sets if data points are \a visible and should be drawn on line. |
|
173 | Sets if data points are \a visible and should be drawn on line. | |
174 | */ |
|
174 | */ | |
175 | void QLineSeries::setPointsVisible(bool visible) |
|
175 | void QLineSeries::setPointsVisible(bool visible) | |
176 | { |
|
176 | { | |
177 | m_pointsVisible=visible; |
|
177 | m_pointsVisible=visible; | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | QDebug operator<< (QDebug debug, const QLineSeries series) |
|
180 | QDebug operator<< (QDebug debug, const QLineSeries series) | |
181 | { |
|
181 | { | |
182 | Q_ASSERT(series.m_x.size() == series.m_y.size()); |
|
182 | Q_ASSERT(series.m_x.size() == series.m_y.size()); | |
183 |
|
183 | |||
184 | int size = series.m_x.size(); |
|
184 | int size = series.m_x.size(); | |
185 |
|
185 | |||
186 | for (int i=0;i<size;i++) { |
|
186 | for (int i=0;i<size;i++) { | |
187 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; |
|
187 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; | |
188 | } |
|
188 | } | |
189 | return debug.space(); |
|
189 | return debug.space(); | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 |
|
192 | |||
193 | #include "moc_qlineseries.cpp" |
|
193 | #include "moc_qlineseries.cpp" | |
194 |
|
194 | |||
195 | QTCOMMERCIALCHART_END_NAMESPACE |
|
195 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now