@@ -1,385 +1,384 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qareaseries.h" |
|
21 | #include "qareaseries.h" | |
22 | #include "qareaseries_p.h" |
|
22 | #include "qareaseries_p.h" | |
23 | #include "qlineseries.h" |
|
23 | #include "qlineseries.h" | |
24 | #include "areachartitem_p.h" |
|
24 | #include "areachartitem_p.h" | |
25 | #include "legendmarker_p.h" |
|
25 | #include "legendmarker_p.h" | |
26 | #include "domain_p.h" |
|
26 | #include "domain_p.h" | |
27 | #include "chartdataset_p.h" |
|
27 | #include "chartdataset_p.h" | |
28 | #include "charttheme_p.h" |
|
28 | #include "charttheme_p.h" | |
29 | #include "chartanimator_p.h" |
|
29 | #include "chartanimator_p.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \class QAreaSeries |
|
34 | \class QAreaSeries | |
35 | \brief The QAreaSeries class is used for making area charts. |
|
35 | \brief The QAreaSeries class is used for making area charts. | |
36 |
|
36 | |||
37 | \mainclass |
|
37 | \mainclass | |
38 |
|
38 | |||
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line |
|
39 | An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line | |
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
40 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. |
|
41 | which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line. | |
42 |
|
|
42 | In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. |
|
43 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
44 |
|
44 | |||
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. |
|
45 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. | |
46 | \image examples_areachart.png |
|
46 | \image examples_areachart.png | |
47 | */ |
|
47 | */ | |
48 | /*! |
|
48 | /*! | |
49 | \qmlclass AreaSeries QAreaSeries |
|
49 | \qmlclass AreaSeries QAreaSeries | |
50 |
|
50 | |||
51 | The following QML shows how to create a simple area chart: |
|
51 | The following QML shows how to create a simple area chart: | |
52 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 |
|
52 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 | |
53 | \beginfloatleft |
|
53 | \beginfloatleft | |
54 | \image demos_qmlchart4.png |
|
54 | \image demos_qmlchart4.png | |
55 | \endfloat |
|
55 | \endfloat | |
56 | \clearfloat |
|
56 | \clearfloat | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | \property QAreaSeries::upperSeries |
|
60 | \property QAreaSeries::upperSeries | |
61 | \brief The upper one of the two line series used to define area series boundaries. |
|
61 | \brief The upper one of the two line series used to define area series boundaries. | |
62 | */ |
|
62 | */ | |
63 | /*! |
|
63 | /*! | |
64 | \qmlproperty LineSeries AreaSeries::upperSeries |
|
64 | \qmlproperty LineSeries AreaSeries::upperSeries | |
65 | The upper one of the two line series used to define area series boundaries. |
|
65 | The upper one of the two line series used to define area series boundaries. | |
66 | */ |
|
66 | */ | |
67 |
|
67 | |||
68 | /*! |
|
68 | /*! | |
69 | \property QAreaSeries::lowerSeries |
|
69 | \property QAreaSeries::lowerSeries | |
70 | The lower one of the two line series used to define are series boundaries. Note if |
|
70 | The lower one of the two line series used to define are series boundaries. Note if | |
71 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
71 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
72 | */ |
|
72 | */ | |
73 | /*! |
|
73 | /*! | |
74 | \qmlproperty LineSeries AreaSeries::lowerSeries |
|
74 | \qmlproperty LineSeries AreaSeries::lowerSeries | |
75 | The lower one of the two line series used to define are series boundaries. Note if |
|
75 | The lower one of the two line series used to define are series boundaries. Note if | |
76 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
76 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \property QAreaSeries::color |
|
80 | \property QAreaSeries::color | |
81 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. |
|
81 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |
82 | \sa QAreaSeries::brush() |
|
82 | \sa QAreaSeries::brush() | |
83 | */ |
|
83 | */ | |
84 | /*! |
|
84 | /*! | |
85 | \qmlproperty color AreaSeries::color |
|
85 | \qmlproperty color AreaSeries::color | |
86 | Fill (brush) color of the series. |
|
86 | Fill (brush) color of the series. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | \property QAreaSeries::borderColor |
|
90 | \property QAreaSeries::borderColor | |
91 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. |
|
91 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
92 | \sa QAreaSeries::pen() |
|
92 | \sa QAreaSeries::pen() | |
93 | */ |
|
93 | */ | |
94 | /*! |
|
94 | /*! | |
95 | \qmlproperty color AreaSeries::borderColor |
|
95 | \qmlproperty color AreaSeries::borderColor | |
96 | Line (pen) color of the series. |
|
96 | Line (pen) color of the series. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \fn QPen QAreaSeries::pen() const |
|
100 | \fn QPen QAreaSeries::pen() const | |
101 | \brief Returns the pen used to draw line for this series. |
|
101 | \brief Returns the pen used to draw line for this series. | |
102 | \sa setPen() |
|
102 | \sa setPen() | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \fn QPen QAreaSeries::brush() const |
|
106 | \fn QPen QAreaSeries::brush() const | |
107 | \brief Returns the brush used to draw line for this series. |
|
107 | \brief Returns the brush used to draw line for this series. | |
108 | \sa setBrush() |
|
108 | \sa setBrush() | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | \fn void QAreaSeries::colorChanged(QColor color) |
|
112 | \fn void QAreaSeries::colorChanged(QColor color) | |
113 | \brief Signal is emitted when the fill (brush) color has changed to \a color. |
|
113 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |
114 | */ |
|
114 | */ | |
115 | /*! |
|
115 | /*! | |
116 | \qmlsignal AreaSeries::colorChanged(color color) |
|
116 | \qmlsignal AreaSeries::colorChanged(color color) | |
117 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
117 | Signal is emitted when the fill (brush) color has changed to \a color. | |
118 | */ |
|
118 | */ | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | \fn void QAreaSeries::borderColorChanged(QColor color) |
|
121 | \fn void QAreaSeries::borderColorChanged(QColor color) | |
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
122 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
123 | */ |
|
123 | */ | |
124 | /*! |
|
124 | /*! | |
125 | \qmlsignal AreaSeries::borderColorChanged(color color) |
|
125 | \qmlsignal AreaSeries::borderColorChanged(color color) | |
126 | Signal is emitted when the line (pen) color has changed to \a color. |
|
126 | Signal is emitted when the line (pen) color has changed to \a color. | |
127 | */ |
|
127 | */ | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
130 | \fn void QAreaSeries::clicked(const QPointF& point) | |
131 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
131 | \brief Signal is emitted when user clicks the \a point on area chart. | |
132 | */ |
|
132 | */ | |
133 | /*! |
|
133 | /*! | |
134 | \qmlsignal AreaSeries::clicked(QPointF point) |
|
134 | \qmlsignal AreaSeries::clicked(QPointF point) | |
135 | Signal is emitted when user clicks the \a point on area chart. |
|
135 | Signal is emitted when user clicks the \a point on area chart. | |
136 | */ |
|
136 | */ | |
137 |
|
137 | |||
138 | /*! |
|
138 | /*! | |
139 | \fn void QAreaSeries::selected() |
|
139 | \fn void QAreaSeries::selected() | |
140 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
140 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
141 | implemented by the user of QAreaSeries API. |
|
141 | implemented by the user of QAreaSeries API. | |
142 | */ |
|
142 | */ | |
143 | /*! |
|
143 | /*! | |
144 | \qmlsignal AreaSeries::selected() |
|
144 | \qmlsignal AreaSeries::selected() | |
145 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
145 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
146 | implemented by the user of AreaSeries API. |
|
146 | implemented by the user of AreaSeries API. | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | \fn void QAreaSeriesPrivate::updated() |
|
150 | \fn void QAreaSeriesPrivate::updated() | |
151 | \brief \internal |
|
151 | \brief \internal | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | /*! |
|
154 | /*! | |
155 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
155 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
156 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
156 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
157 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
157 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
158 | */ |
|
158 | */ | |
159 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
159 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
160 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) |
|
160 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries) | |
161 | { |
|
161 | { | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | /*! |
|
164 | /*! | |
165 | Constructs area series object without upper or lower series with \a parent object. |
|
165 | Constructs area series object without upper or lower series with \a parent object. | |
166 | */ |
|
166 | */ | |
167 | QAreaSeries::QAreaSeries(QObject *parent) |
|
167 | QAreaSeries::QAreaSeries(QObject *parent) | |
168 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) |
|
168 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) | |
169 | { |
|
169 | { | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | /*! |
|
172 | /*! | |
173 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
173 | Destroys the object. | |
174 | and are deleted when mentioned object are destroyed. |
|
|||
175 | */ |
|
174 | */ | |
176 | QAreaSeries::~QAreaSeries() |
|
175 | QAreaSeries::~QAreaSeries() | |
177 | { |
|
176 | { | |
178 | } |
|
177 | } | |
179 |
|
178 | |||
180 | /*! |
|
179 | /*! | |
181 | Returns QChartSeries::SeriesTypeArea. |
|
180 | Returns QChartSeries::SeriesTypeArea. | |
182 | */ |
|
181 | */ | |
183 | QAbstractSeries::SeriesType QAreaSeries::type() const |
|
182 | QAbstractSeries::SeriesType QAreaSeries::type() const | |
184 | { |
|
183 | { | |
185 | return QAbstractSeries::SeriesTypeArea; |
|
184 | return QAbstractSeries::SeriesTypeArea; | |
186 | } |
|
185 | } | |
187 |
|
186 | |||
188 | /*! |
|
187 | /*! | |
189 | Sets the \a series that is to be used as the area chart upper series. |
|
188 | Sets the \a series that is to be used as the area chart upper series. | |
190 | */ |
|
189 | */ | |
191 | void QAreaSeries::setUpperSeries(QLineSeries* series) |
|
190 | void QAreaSeries::setUpperSeries(QLineSeries* series) | |
192 | { |
|
191 | { | |
193 | Q_D(QAreaSeries); |
|
192 | Q_D(QAreaSeries); | |
194 | d->m_upperSeries = series; |
|
193 | d->m_upperSeries = series; | |
195 | } |
|
194 | } | |
196 |
|
195 | |||
197 | QLineSeries* QAreaSeries::upperSeries() const |
|
196 | QLineSeries* QAreaSeries::upperSeries() const | |
198 | { |
|
197 | { | |
199 | Q_D(const QAreaSeries); |
|
198 | Q_D(const QAreaSeries); | |
200 | return d->m_upperSeries; |
|
199 | return d->m_upperSeries; | |
201 | } |
|
200 | } | |
202 |
|
201 | |||
203 | /*! |
|
202 | /*! | |
204 | Sets the \a series that is to be used as the area chart lower series. |
|
203 | Sets the \a series that is to be used as the area chart lower series. | |
205 | */ |
|
204 | */ | |
206 | void QAreaSeries::setLowerSeries(QLineSeries* series) |
|
205 | void QAreaSeries::setLowerSeries(QLineSeries* series) | |
207 | { |
|
206 | { | |
208 | Q_D(QAreaSeries); |
|
207 | Q_D(QAreaSeries); | |
209 | d->m_lowerSeries = series; |
|
208 | d->m_lowerSeries = series; | |
210 | } |
|
209 | } | |
211 |
|
210 | |||
212 | QLineSeries* QAreaSeries::lowerSeries() const |
|
211 | QLineSeries* QAreaSeries::lowerSeries() const | |
213 | { |
|
212 | { | |
214 | Q_D(const QAreaSeries); |
|
213 | Q_D(const QAreaSeries); | |
215 | return d->m_lowerSeries; |
|
214 | return d->m_lowerSeries; | |
216 | } |
|
215 | } | |
217 |
|
216 | |||
218 | /*! |
|
217 | /*! | |
219 | Sets \a pen used for drawing area outline. |
|
218 | Sets \a pen used for drawing area outline. | |
220 | */ |
|
219 | */ | |
221 | void QAreaSeries::setPen(const QPen &pen) |
|
220 | void QAreaSeries::setPen(const QPen &pen) | |
222 | { |
|
221 | { | |
223 | Q_D(QAreaSeries); |
|
222 | Q_D(QAreaSeries); | |
224 | if (d->m_pen != pen) { |
|
223 | if (d->m_pen != pen) { | |
225 | d->m_pen = pen; |
|
224 | d->m_pen = pen; | |
226 | emit d->updated(); |
|
225 | emit d->updated(); | |
227 | } |
|
226 | } | |
228 | } |
|
227 | } | |
229 |
|
228 | |||
230 | QPen QAreaSeries::pen() const |
|
229 | QPen QAreaSeries::pen() const | |
231 | { |
|
230 | { | |
232 | Q_D(const QAreaSeries); |
|
231 | Q_D(const QAreaSeries); | |
233 | return d->m_pen; |
|
232 | return d->m_pen; | |
234 | } |
|
233 | } | |
235 |
|
234 | |||
236 | /*! |
|
235 | /*! | |
237 | Sets \a brush used for filling the area. |
|
236 | Sets \a brush used for filling the area. | |
238 | */ |
|
237 | */ | |
239 | void QAreaSeries::setBrush(const QBrush &brush) |
|
238 | void QAreaSeries::setBrush(const QBrush &brush) | |
240 | { |
|
239 | { | |
241 | Q_D(QAreaSeries); |
|
240 | Q_D(QAreaSeries); | |
242 | if (d->m_brush != brush) { |
|
241 | if (d->m_brush != brush) { | |
243 | d->m_brush = brush; |
|
242 | d->m_brush = brush; | |
244 | emit d->updated(); |
|
243 | emit d->updated(); | |
245 | } |
|
244 | } | |
246 | } |
|
245 | } | |
247 |
|
246 | |||
248 | QBrush QAreaSeries::brush() const |
|
247 | QBrush QAreaSeries::brush() const | |
249 | { |
|
248 | { | |
250 | Q_D(const QAreaSeries); |
|
249 | Q_D(const QAreaSeries); | |
251 | return d->m_brush; |
|
250 | return d->m_brush; | |
252 | } |
|
251 | } | |
253 |
|
252 | |||
254 | void QAreaSeries::setColor(const QColor &color) |
|
253 | void QAreaSeries::setColor(const QColor &color) | |
255 | { |
|
254 | { | |
256 | QBrush b = brush(); |
|
255 | QBrush b = brush(); | |
257 | if (b.color() != color) { |
|
256 | if (b.color() != color) { | |
258 | b.setColor(color); |
|
257 | b.setColor(color); | |
259 | setBrush(b); |
|
258 | setBrush(b); | |
260 | emit colorChanged(color); |
|
259 | emit colorChanged(color); | |
261 | } |
|
260 | } | |
262 | } |
|
261 | } | |
263 |
|
262 | |||
264 | QColor QAreaSeries::color() const |
|
263 | QColor QAreaSeries::color() const | |
265 | { |
|
264 | { | |
266 | return brush().color(); |
|
265 | return brush().color(); | |
267 | } |
|
266 | } | |
268 |
|
267 | |||
269 | void QAreaSeries::setBorderColor(const QColor &color) |
|
268 | void QAreaSeries::setBorderColor(const QColor &color) | |
270 | { |
|
269 | { | |
271 | QPen p = pen(); |
|
270 | QPen p = pen(); | |
272 | if (p.color() != color) { |
|
271 | if (p.color() != color) { | |
273 | p.setColor(color); |
|
272 | p.setColor(color); | |
274 | setPen(p); |
|
273 | setPen(p); | |
275 | emit borderColorChanged(color); |
|
274 | emit borderColorChanged(color); | |
276 | } |
|
275 | } | |
277 | } |
|
276 | } | |
278 |
|
277 | |||
279 | QColor QAreaSeries::borderColor() const |
|
278 | QColor QAreaSeries::borderColor() const | |
280 | { |
|
279 | { | |
281 | return pen().color(); |
|
280 | return pen().color(); | |
282 | } |
|
281 | } | |
283 |
|
282 | |||
284 | /*! |
|
283 | /*! | |
285 | Sets if data points are \a visible and should be drawn on line. |
|
284 | Sets if data points are \a visible and should be drawn on line. | |
286 | */ |
|
285 | */ | |
287 | void QAreaSeries::setPointsVisible(bool visible) |
|
286 | void QAreaSeries::setPointsVisible(bool visible) | |
288 | { |
|
287 | { | |
289 | Q_D(QAreaSeries); |
|
288 | Q_D(QAreaSeries); | |
290 | if (d->m_pointsVisible != visible) { |
|
289 | if (d->m_pointsVisible != visible) { | |
291 | d->m_pointsVisible = visible; |
|
290 | d->m_pointsVisible = visible; | |
292 | emit d->updated(); |
|
291 | emit d->updated(); | |
293 | } |
|
292 | } | |
294 | } |
|
293 | } | |
295 |
|
294 | |||
296 | /*! |
|
295 | /*! | |
297 | Returns if the points are drawn for this series. |
|
296 | Returns if the points are drawn for this series. | |
298 | \sa setPointsVisible() |
|
297 | \sa setPointsVisible() | |
299 | */ |
|
298 | */ | |
300 | bool QAreaSeries::pointsVisible() const |
|
299 | bool QAreaSeries::pointsVisible() const | |
301 | { |
|
300 | { | |
302 | Q_D(const QAreaSeries); |
|
301 | Q_D(const QAreaSeries); | |
303 | return d->m_pointsVisible; |
|
302 | return d->m_pointsVisible; | |
304 | } |
|
303 | } | |
305 |
|
304 | |||
306 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
305 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
307 |
|
306 | |||
308 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : |
|
307 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) : | |
309 | QAbstractSeriesPrivate(q), |
|
308 | QAbstractSeriesPrivate(q), | |
310 | m_upperSeries(upperSeries), |
|
309 | m_upperSeries(upperSeries), | |
311 | m_lowerSeries(lowerSeries), |
|
310 | m_lowerSeries(lowerSeries), | |
312 | m_pointsVisible(false) |
|
311 | m_pointsVisible(false) | |
313 | { |
|
312 | { | |
314 | } |
|
313 | } | |
315 |
|
314 | |||
316 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) |
|
315 | void QAreaSeriesPrivate::scaleDomain(Domain& domain) | |
317 | { |
|
316 | { | |
318 | Q_Q(QAreaSeries); |
|
317 | Q_Q(QAreaSeries); | |
319 |
|
318 | |||
320 | qreal minX(domain.minX()); |
|
319 | qreal minX(domain.minX()); | |
321 | qreal minY(domain.minY()); |
|
320 | qreal minY(domain.minY()); | |
322 | qreal maxX(domain.maxX()); |
|
321 | qreal maxX(domain.maxX()); | |
323 | qreal maxY(domain.maxY()); |
|
322 | qreal maxY(domain.maxY()); | |
324 | int tickXCount(domain.tickXCount()); |
|
323 | int tickXCount(domain.tickXCount()); | |
325 | int tickYCount(domain.tickYCount()); |
|
324 | int tickYCount(domain.tickYCount()); | |
326 |
|
325 | |||
327 | QLineSeries* upperSeries = q->upperSeries(); |
|
326 | QLineSeries* upperSeries = q->upperSeries(); | |
328 | QLineSeries* lowerSeries = q->lowerSeries(); |
|
327 | QLineSeries* lowerSeries = q->lowerSeries(); | |
329 |
|
328 | |||
330 | const QList<QPointF>& points = upperSeries->points(); |
|
329 | const QList<QPointF>& points = upperSeries->points(); | |
331 |
|
330 | |||
332 | for (int i = 0; i < points.count(); i++) |
|
331 | for (int i = 0; i < points.count(); i++) | |
333 | { |
|
332 | { | |
334 | qreal x = points[i].x(); |
|
333 | qreal x = points[i].x(); | |
335 | qreal y = points[i].y(); |
|
334 | qreal y = points[i].y(); | |
336 | minX = qMin(minX, x); |
|
335 | minX = qMin(minX, x); | |
337 | minY = qMin(minY, y); |
|
336 | minY = qMin(minY, y); | |
338 | maxX = qMax(maxX, x); |
|
337 | maxX = qMax(maxX, x); | |
339 | maxY = qMax(maxY, y); |
|
338 | maxY = qMax(maxY, y); | |
340 | } |
|
339 | } | |
341 | if(lowerSeries) { |
|
340 | if(lowerSeries) { | |
342 |
|
341 | |||
343 | const QList<QPointF>& points = lowerSeries->points(); |
|
342 | const QList<QPointF>& points = lowerSeries->points(); | |
344 |
|
343 | |||
345 | for (int i = 0; i < points.count(); i++) |
|
344 | for (int i = 0; i < points.count(); i++) | |
346 | { |
|
345 | { | |
347 | qreal x = points[i].x(); |
|
346 | qreal x = points[i].x(); | |
348 | qreal y = points[i].y(); |
|
347 | qreal y = points[i].y(); | |
349 | minX = qMin(minX, x); |
|
348 | minX = qMin(minX, x); | |
350 | minY = qMin(minY, y); |
|
349 | minY = qMin(minY, y); | |
351 | maxX = qMax(maxX, x); |
|
350 | maxX = qMax(maxX, x); | |
352 | maxY = qMax(maxY, y); |
|
351 | maxY = qMax(maxY, y); | |
353 | }} |
|
352 | }} | |
354 |
|
353 | |||
355 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); |
|
354 | domain.setRange(minX,maxX,minY,maxY,tickXCount,tickYCount); | |
356 | } |
|
355 | } | |
357 |
|
356 | |||
358 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
357 | Chart* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter) | |
359 | { |
|
358 | { | |
360 | Q_Q(QAreaSeries); |
|
359 | Q_Q(QAreaSeries); | |
361 |
|
360 | |||
362 | AreaChartItem* area = new AreaChartItem(q,presenter); |
|
361 | AreaChartItem* area = new AreaChartItem(q,presenter); | |
363 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
362 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | |
364 | area->upperLineItem()->setAnimator(presenter->animator()); |
|
363 | area->upperLineItem()->setAnimator(presenter->animator()); | |
365 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
364 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
366 | if(q->lowerSeries()) { |
|
365 | if(q->lowerSeries()) { | |
367 | area->lowerLineItem()->setAnimator(presenter->animator()); |
|
366 | area->lowerLineItem()->setAnimator(presenter->animator()); | |
368 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
367 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
369 | } |
|
368 | } | |
370 | } |
|
369 | } | |
371 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
370 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | |
372 | return area; |
|
371 | return area; | |
373 | } |
|
372 | } | |
374 |
|
373 | |||
375 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) |
|
374 | QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |
376 | { |
|
375 | { | |
377 | Q_Q(QAreaSeries); |
|
376 | Q_Q(QAreaSeries); | |
378 | QList<LegendMarker*> list; |
|
377 | QList<LegendMarker*> list; | |
379 | return list << new AreaLegendMarker(q,legend); |
|
378 | return list << new AreaLegendMarker(q,legend); | |
380 | } |
|
379 | } | |
381 |
|
380 | |||
382 | #include "moc_qareaseries.cpp" |
|
381 | #include "moc_qareaseries.cpp" | |
383 | #include "moc_qareaseries_p.cpp" |
|
382 | #include "moc_qareaseries_p.cpp" | |
384 |
|
383 | |||
385 | QTCOMMERCIALCHART_END_NAMESPACE |
|
384 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now