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