@@ -1,441 +1,454 | |||||
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 "abstractdomain_p.h" |
|
25 | #include "abstractdomain_p.h" | |
26 | #include "chartdataset_p.h" |
|
26 | #include "chartdataset_p.h" | |
27 | #include "charttheme_p.h" |
|
27 | #include "charttheme_p.h" | |
28 | #include "qvalueaxis.h" |
|
28 | #include "qvalueaxis.h" | |
29 | #include "qarealegendmarker.h" |
|
29 | #include "qarealegendmarker.h" | |
30 | #include "qchart_p.h" |
|
30 | #include "qchart_p.h" | |
31 |
|
31 | |||
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
33 |
|
33 | |||
34 | /*! |
|
34 | /*! | |
35 | \class QAreaSeries |
|
35 | \class QAreaSeries | |
36 | \brief The QAreaSeries class is used for making area charts. |
|
36 | \brief The QAreaSeries class is used for making area charts. | |
37 |
|
37 | |||
38 | \mainclass |
|
38 | \mainclass | |
39 |
|
39 | |||
40 | 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 | 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 | |
41 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, |
|
41 | is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance, | |
42 | 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 | 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. | |
43 | In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases |
|
43 | In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases | |
44 | 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 | where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled. | |
45 |
|
45 | |||
46 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. |
|
46 | See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart. | |
47 | \image examples_areachart.png |
|
47 | \image examples_areachart.png | |
48 | */ |
|
48 | */ | |
49 | /*! |
|
49 | /*! | |
50 | \qmlclass AreaSeries QAreaSeries |
|
50 | \qmlclass AreaSeries QAreaSeries | |
51 |
|
51 | |||
52 | The following QML shows how to create a simple area chart: |
|
52 | The following QML shows how to create a simple area chart: | |
53 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 |
|
53 | \snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1 | |
54 | \beginfloatleft |
|
54 | \beginfloatleft | |
55 | \image demos_qmlchart4.png |
|
55 | \image demos_qmlchart4.png | |
56 | \endfloat |
|
56 | \endfloat | |
57 | \clearfloat |
|
57 | \clearfloat | |
58 | */ |
|
58 | */ | |
59 |
|
59 | |||
60 | /*! |
|
60 | /*! | |
61 | \property QAreaSeries::upperSeries |
|
61 | \property QAreaSeries::upperSeries | |
62 | \brief The upper one of the two line series used to define area series boundaries. |
|
62 | \brief The upper one of the two line series used to define area series boundaries. | |
63 | */ |
|
63 | */ | |
64 | /*! |
|
64 | /*! | |
65 | \qmlproperty LineSeries AreaSeries::upperSeries |
|
65 | \qmlproperty LineSeries AreaSeries::upperSeries | |
66 | The upper one of the two line series used to define area series boundaries. |
|
66 | The upper one of the two line series used to define area series boundaries. | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \property QAreaSeries::lowerSeries |
|
70 | \property QAreaSeries::lowerSeries | |
71 | The lower one of the two line series used to define are series boundaries. Note if |
|
71 | The lower one of the two line series used to define are series boundaries. Note if | |
72 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
72 | QAreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
73 | */ |
|
73 | */ | |
74 | /*! |
|
74 | /*! | |
75 | \qmlproperty LineSeries AreaSeries::lowerSeries |
|
75 | \qmlproperty LineSeries AreaSeries::lowerSeries | |
76 | The lower one of the two line series used to define are series boundaries. Note if |
|
76 | The lower one of the two line series used to define are series boundaries. Note if | |
77 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. |
|
77 | AreaSeries was counstucted wihtout a\ lowerSeries this is null. | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QAreaSeries::color |
|
81 | \property QAreaSeries::color | |
82 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. |
|
82 | Fill (brush) color of the series. This is a convenience property for modifying the color of brush. | |
83 | \sa QAreaSeries::brush() |
|
83 | \sa QAreaSeries::brush() | |
84 | */ |
|
84 | */ | |
85 | /*! |
|
85 | /*! | |
86 | \qmlproperty color AreaSeries::color |
|
86 | \qmlproperty color AreaSeries::color | |
87 | Fill (brush) color of the series. |
|
87 | Fill (brush) color of the series. | |
88 | */ |
|
88 | */ | |
89 |
|
89 | |||
90 | /*! |
|
90 | /*! | |
91 | \property QAreaSeries::borderColor |
|
91 | \property QAreaSeries::borderColor | |
92 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. |
|
92 | Line (pen) color of the series. This is a convenience property for modifying the color of pen. | |
93 | \sa QAreaSeries::pen() |
|
93 | \sa QAreaSeries::pen() | |
94 | */ |
|
94 | */ | |
95 | /*! |
|
95 | /*! | |
96 | \qmlproperty color AreaSeries::borderColor |
|
96 | \qmlproperty color AreaSeries::borderColor | |
97 | Line (pen) color of the series. |
|
97 | Line (pen) color of the series. | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | /*! |
|
100 | /*! | |
101 | \qmlproperty real AreaSeries::borderWidth |
|
101 | \qmlproperty real AreaSeries::borderWidth | |
102 | The width of the border line. By default the width is 2.0. |
|
102 | The width of the border line. By default the width is 2.0. | |
103 | */ |
|
103 | */ | |
104 |
|
104 | |||
105 | /*! |
|
105 | /*! | |
106 | \fn QPen QAreaSeries::pen() const |
|
106 | \fn QPen QAreaSeries::pen() const | |
107 | \brief Returns the pen used to draw line for this series. |
|
107 | \brief Returns the pen used to draw line for this series. | |
108 | \sa setPen() |
|
108 | \sa setPen() | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | /*! |
|
111 | /*! | |
112 | \fn QPen QAreaSeries::brush() const |
|
112 | \fn QPen QAreaSeries::brush() const | |
113 | \brief Returns the brush used to draw line for this series. |
|
113 | \brief Returns the brush used to draw line for this series. | |
114 | \sa setBrush() |
|
114 | \sa setBrush() | |
115 | */ |
|
115 | */ | |
116 |
|
116 | |||
117 | /*! |
|
117 | /*! | |
118 | \fn void QAreaSeries::colorChanged(QColor color) |
|
118 | \fn void QAreaSeries::colorChanged(QColor color) | |
119 | \brief Signal is emitted when the fill (brush) color has changed to \a color. |
|
119 | \brief Signal is emitted when the fill (brush) color has changed to \a color. | |
120 | */ |
|
120 | */ | |
121 | /*! |
|
121 | /*! | |
122 | \qmlsignal AreaSeries::onColorChanged(color color) |
|
122 | \qmlsignal AreaSeries::onColorChanged(color color) | |
123 | Signal is emitted when the fill (brush) color has changed to \a color. |
|
123 | Signal is emitted when the fill (brush) color has changed to \a color. | |
124 | */ |
|
124 | */ | |
125 |
|
125 | |||
126 | /*! |
|
126 | /*! | |
127 | \fn void QAreaSeries::borderColorChanged(QColor color) |
|
127 | \fn void QAreaSeries::borderColorChanged(QColor color) | |
128 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
128 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
129 | */ |
|
129 | */ | |
130 | /*! |
|
130 | /*! | |
131 | \qmlsignal AreaSeries::onBorderColorChanged(color color) |
|
131 | \qmlsignal AreaSeries::onBorderColorChanged(color color) | |
132 | Signal is emitted when the line (pen) color has changed to \a color. |
|
132 | Signal is emitted when the line (pen) color has changed to \a color. | |
133 | */ |
|
133 | */ | |
134 |
|
134 | |||
135 | /*! |
|
135 | /*! | |
136 | \fn void QAreaSeries::clicked(const QPointF& point) |
|
136 | \fn void QAreaSeries::clicked(const QPointF& point) | |
137 | \brief Signal is emitted when user clicks the \a point on area chart. |
|
137 | \brief Signal is emitted when user clicks the \a point on area chart. | |
138 | */ |
|
138 | */ | |
139 | /*! |
|
139 | /*! | |
140 | \qmlsignal AreaSeries::onClicked(QPointF point) |
|
140 | \qmlsignal AreaSeries::onClicked(QPointF point) | |
141 | Signal is emitted when user clicks the \a point on area chart. |
|
141 | Signal is emitted when user clicks the \a point on area chart. | |
142 | */ |
|
142 | */ | |
143 |
|
143 | |||
144 | /*! |
|
144 | /*! | |
|
145 | \fn void QAreaSeries::hovered(const QPointF &point, bool state) | |||
|
146 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |||
|
147 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |||
|
148 | the series. | |||
|
149 | */ | |||
|
150 | /*! | |||
|
151 | \qmlsignal AreaSeries::onHovered(point point, bool state) | |||
|
152 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |||
|
153 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |||
|
154 | the series. | |||
|
155 | */ | |||
|
156 | ||||
|
157 | /*! | |||
145 | \fn void QAreaSeries::selected() |
|
158 | \fn void QAreaSeries::selected() | |
146 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
159 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
147 | implemented by the user of QAreaSeries API. |
|
160 | implemented by the user of QAreaSeries API. | |
148 | */ |
|
161 | */ | |
149 | /*! |
|
162 | /*! | |
150 | \qmlsignal AreaSeries::onSelected() |
|
163 | \qmlsignal AreaSeries::onSelected() | |
151 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be |
|
164 | The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be | |
152 | implemented by the user of AreaSeries API. |
|
165 | implemented by the user of AreaSeries API. | |
153 | */ |
|
166 | */ | |
154 |
|
167 | |||
155 | /*! |
|
168 | /*! | |
156 | \fn void QAreaSeriesPrivate::updated() |
|
169 | \fn void QAreaSeriesPrivate::updated() | |
157 | \brief \internal |
|
170 | \brief \internal | |
158 | */ |
|
171 | */ | |
159 |
|
172 | |||
160 | /*! |
|
173 | /*! | |
161 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a |
|
174 | Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a | |
162 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. |
|
175 | upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. | |
163 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
176 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
164 | */ |
|
177 | */ | |
165 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) |
|
178 | QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) | |
166 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries, lowerSeries, this), upperSeries) |
|
179 | : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries, lowerSeries, this), upperSeries) | |
167 | { |
|
180 | { | |
168 | } |
|
181 | } | |
169 |
|
182 | |||
170 | /*! |
|
183 | /*! | |
171 | Constructs area series object without upper or lower series with \a parent object. |
|
184 | Constructs area series object without upper or lower series with \a parent object. | |
172 | */ |
|
185 | */ | |
173 | QAreaSeries::QAreaSeries(QObject *parent) |
|
186 | QAreaSeries::QAreaSeries(QObject *parent) | |
174 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) |
|
187 | : QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent) | |
175 | { |
|
188 | { | |
176 | } |
|
189 | } | |
177 |
|
190 | |||
178 | /*! |
|
191 | /*! | |
179 | Destroys the object. |
|
192 | Destroys the object. | |
180 | */ |
|
193 | */ | |
181 | QAreaSeries::~QAreaSeries() |
|
194 | QAreaSeries::~QAreaSeries() | |
182 | { |
|
195 | { | |
183 | Q_D(QAreaSeries); |
|
196 | Q_D(QAreaSeries); | |
184 | if (d->m_chart) |
|
197 | if (d->m_chart) | |
185 | d->m_chart->removeSeries(this); |
|
198 | d->m_chart->removeSeries(this); | |
186 | } |
|
199 | } | |
187 |
|
200 | |||
188 | /*! |
|
201 | /*! | |
189 | Returns QChartSeries::SeriesTypeArea. |
|
202 | Returns QChartSeries::SeriesTypeArea. | |
190 | */ |
|
203 | */ | |
191 | QAbstractSeries::SeriesType QAreaSeries::type() const |
|
204 | QAbstractSeries::SeriesType QAreaSeries::type() const | |
192 | { |
|
205 | { | |
193 | return QAbstractSeries::SeriesTypeArea; |
|
206 | return QAbstractSeries::SeriesTypeArea; | |
194 | } |
|
207 | } | |
195 |
|
208 | |||
196 | /*! |
|
209 | /*! | |
197 | Sets the \a series that is to be used as the area chart upper series. |
|
210 | Sets the \a series that is to be used as the area chart upper series. | |
198 | */ |
|
211 | */ | |
199 | void QAreaSeries::setUpperSeries(QLineSeries *series) |
|
212 | void QAreaSeries::setUpperSeries(QLineSeries *series) | |
200 | { |
|
213 | { | |
201 | Q_D(QAreaSeries); |
|
214 | Q_D(QAreaSeries); | |
202 | if(d->m_upperSeries!=series){ |
|
215 | if(d->m_upperSeries!=series){ | |
203 | d->m_upperSeries = series; |
|
216 | d->m_upperSeries = series; | |
204 | //TODO: |
|
217 | //TODO: | |
205 | } |
|
218 | } | |
206 | } |
|
219 | } | |
207 |
|
220 | |||
208 | QLineSeries *QAreaSeries::upperSeries() const |
|
221 | QLineSeries *QAreaSeries::upperSeries() const | |
209 | { |
|
222 | { | |
210 | Q_D(const QAreaSeries); |
|
223 | Q_D(const QAreaSeries); | |
211 | return d->m_upperSeries; |
|
224 | return d->m_upperSeries; | |
212 | } |
|
225 | } | |
213 |
|
226 | |||
214 | /*! |
|
227 | /*! | |
215 | Sets the \a series that is to be used as the area chart lower series. |
|
228 | Sets the \a series that is to be used as the area chart lower series. | |
216 | */ |
|
229 | */ | |
217 | void QAreaSeries::setLowerSeries(QLineSeries *series) |
|
230 | void QAreaSeries::setLowerSeries(QLineSeries *series) | |
218 | { |
|
231 | { | |
219 | Q_D(QAreaSeries); |
|
232 | Q_D(QAreaSeries); | |
220 | d->m_lowerSeries = series; |
|
233 | d->m_lowerSeries = series; | |
221 | } |
|
234 | } | |
222 |
|
235 | |||
223 | QLineSeries *QAreaSeries::lowerSeries() const |
|
236 | QLineSeries *QAreaSeries::lowerSeries() const | |
224 | { |
|
237 | { | |
225 | Q_D(const QAreaSeries); |
|
238 | Q_D(const QAreaSeries); | |
226 | return d->m_lowerSeries; |
|
239 | return d->m_lowerSeries; | |
227 | } |
|
240 | } | |
228 |
|
241 | |||
229 | /*! |
|
242 | /*! | |
230 | Sets \a pen used for drawing area outline. |
|
243 | Sets \a pen used for drawing area outline. | |
231 | */ |
|
244 | */ | |
232 | void QAreaSeries::setPen(const QPen &pen) |
|
245 | void QAreaSeries::setPen(const QPen &pen) | |
233 | { |
|
246 | { | |
234 | Q_D(QAreaSeries); |
|
247 | Q_D(QAreaSeries); | |
235 | if (d->m_pen != pen) { |
|
248 | if (d->m_pen != pen) { | |
236 | d->m_pen = pen; |
|
249 | d->m_pen = pen; | |
237 | emit d->updated(); |
|
250 | emit d->updated(); | |
238 | } |
|
251 | } | |
239 | } |
|
252 | } | |
240 |
|
253 | |||
241 | QPen QAreaSeries::pen() const |
|
254 | QPen QAreaSeries::pen() const | |
242 | { |
|
255 | { | |
243 | Q_D(const QAreaSeries); |
|
256 | Q_D(const QAreaSeries); | |
244 | return d->m_pen; |
|
257 | return d->m_pen; | |
245 | } |
|
258 | } | |
246 |
|
259 | |||
247 | /*! |
|
260 | /*! | |
248 | Sets \a brush used for filling the area. |
|
261 | Sets \a brush used for filling the area. | |
249 | */ |
|
262 | */ | |
250 | void QAreaSeries::setBrush(const QBrush &brush) |
|
263 | void QAreaSeries::setBrush(const QBrush &brush) | |
251 | { |
|
264 | { | |
252 | Q_D(QAreaSeries); |
|
265 | Q_D(QAreaSeries); | |
253 | if (d->m_brush != brush) { |
|
266 | if (d->m_brush != brush) { | |
254 | bool emitColorChanged = brush.color() != d->m_brush.color(); |
|
267 | bool emitColorChanged = brush.color() != d->m_brush.color(); | |
255 | d->m_brush = brush; |
|
268 | d->m_brush = brush; | |
256 | emit d->updated(); |
|
269 | emit d->updated(); | |
257 | if (emitColorChanged) |
|
270 | if (emitColorChanged) | |
258 | emit colorChanged(brush.color()); |
|
271 | emit colorChanged(brush.color()); | |
259 | } |
|
272 | } | |
260 | } |
|
273 | } | |
261 |
|
274 | |||
262 | QBrush QAreaSeries::brush() const |
|
275 | QBrush QAreaSeries::brush() const | |
263 | { |
|
276 | { | |
264 | Q_D(const QAreaSeries); |
|
277 | Q_D(const QAreaSeries); | |
265 | return d->m_brush; |
|
278 | return d->m_brush; | |
266 | } |
|
279 | } | |
267 |
|
280 | |||
268 | void QAreaSeries::setColor(const QColor &color) |
|
281 | void QAreaSeries::setColor(const QColor &color) | |
269 | { |
|
282 | { | |
270 | QBrush b = brush(); |
|
283 | QBrush b = brush(); | |
271 | if (b == QBrush()) |
|
284 | if (b == QBrush()) | |
272 | b.setStyle(Qt::SolidPattern); |
|
285 | b.setStyle(Qt::SolidPattern); | |
273 | b.setColor(color); |
|
286 | b.setColor(color); | |
274 | setBrush(b); |
|
287 | setBrush(b); | |
275 | } |
|
288 | } | |
276 |
|
289 | |||
277 | QColor QAreaSeries::color() const |
|
290 | QColor QAreaSeries::color() const | |
278 | { |
|
291 | { | |
279 | return brush().color(); |
|
292 | return brush().color(); | |
280 | } |
|
293 | } | |
281 |
|
294 | |||
282 | void QAreaSeries::setBorderColor(const QColor &color) |
|
295 | void QAreaSeries::setBorderColor(const QColor &color) | |
283 | { |
|
296 | { | |
284 | QPen p = pen(); |
|
297 | QPen p = pen(); | |
285 | if (p.color() != color) { |
|
298 | if (p.color() != color) { | |
286 | p.setColor(color); |
|
299 | p.setColor(color); | |
287 | setPen(p); |
|
300 | setPen(p); | |
288 | emit borderColorChanged(color); |
|
301 | emit borderColorChanged(color); | |
289 | } |
|
302 | } | |
290 | } |
|
303 | } | |
291 |
|
304 | |||
292 | QColor QAreaSeries::borderColor() const |
|
305 | QColor QAreaSeries::borderColor() const | |
293 | { |
|
306 | { | |
294 | return pen().color(); |
|
307 | return pen().color(); | |
295 | } |
|
308 | } | |
296 |
|
309 | |||
297 | /*! |
|
310 | /*! | |
298 | Sets if data points are \a visible and should be drawn on line. |
|
311 | Sets if data points are \a visible and should be drawn on line. | |
299 | */ |
|
312 | */ | |
300 | void QAreaSeries::setPointsVisible(bool visible) |
|
313 | void QAreaSeries::setPointsVisible(bool visible) | |
301 | { |
|
314 | { | |
302 | Q_D(QAreaSeries); |
|
315 | Q_D(QAreaSeries); | |
303 | if (d->m_pointsVisible != visible) { |
|
316 | if (d->m_pointsVisible != visible) { | |
304 | d->m_pointsVisible = visible; |
|
317 | d->m_pointsVisible = visible; | |
305 | emit d->updated(); |
|
318 | emit d->updated(); | |
306 | } |
|
319 | } | |
307 | } |
|
320 | } | |
308 |
|
321 | |||
309 | /*! |
|
322 | /*! | |
310 | Returns if the points are drawn for this series. |
|
323 | Returns if the points are drawn for this series. | |
311 | \sa setPointsVisible() |
|
324 | \sa setPointsVisible() | |
312 | */ |
|
325 | */ | |
313 | bool QAreaSeries::pointsVisible() const |
|
326 | bool QAreaSeries::pointsVisible() const | |
314 | { |
|
327 | { | |
315 | Q_D(const QAreaSeries); |
|
328 | Q_D(const QAreaSeries); | |
316 | return d->m_pointsVisible; |
|
329 | return d->m_pointsVisible; | |
317 | } |
|
330 | } | |
318 |
|
331 | |||
319 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
332 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
320 |
|
333 | |||
321 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries *q) |
|
334 | QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries, QAreaSeries *q) | |
322 | : QAbstractSeriesPrivate(q), |
|
335 | : QAbstractSeriesPrivate(q), | |
323 | m_upperSeries(upperSeries), |
|
336 | m_upperSeries(upperSeries), | |
324 | m_lowerSeries(lowerSeries), |
|
337 | m_lowerSeries(lowerSeries), | |
325 | m_pointsVisible(false) |
|
338 | m_pointsVisible(false) | |
326 | { |
|
339 | { | |
327 | } |
|
340 | } | |
328 |
|
341 | |||
329 | void QAreaSeriesPrivate::initializeDomain() |
|
342 | void QAreaSeriesPrivate::initializeDomain() | |
330 | { |
|
343 | { | |
331 | Q_Q(QAreaSeries); |
|
344 | Q_Q(QAreaSeries); | |
332 |
|
345 | |||
333 | qreal minX(domain()->minX()); |
|
346 | qreal minX(domain()->minX()); | |
334 | qreal minY(domain()->minY()); |
|
347 | qreal minY(domain()->minY()); | |
335 | qreal maxX(domain()->maxX()); |
|
348 | qreal maxX(domain()->maxX()); | |
336 | qreal maxY(domain()->maxY()); |
|
349 | qreal maxY(domain()->maxY()); | |
337 |
|
350 | |||
338 | QLineSeries *upperSeries = q->upperSeries(); |
|
351 | QLineSeries *upperSeries = q->upperSeries(); | |
339 | QLineSeries *lowerSeries = q->lowerSeries(); |
|
352 | QLineSeries *lowerSeries = q->lowerSeries(); | |
340 |
|
353 | |||
341 | const QList<QPointF>& points = upperSeries->points(); |
|
354 | const QList<QPointF>& points = upperSeries->points(); | |
342 |
|
355 | |||
343 | for (int i = 0; i < points.count(); i++) { |
|
356 | for (int i = 0; i < points.count(); i++) { | |
344 | qreal x = points[i].x(); |
|
357 | qreal x = points[i].x(); | |
345 | qreal y = points[i].y(); |
|
358 | qreal y = points[i].y(); | |
346 | minX = qMin(minX, x); |
|
359 | minX = qMin(minX, x); | |
347 | minY = qMin(minY, y); |
|
360 | minY = qMin(minY, y); | |
348 | maxX = qMax(maxX, x); |
|
361 | maxX = qMax(maxX, x); | |
349 | maxY = qMax(maxY, y); |
|
362 | maxY = qMax(maxY, y); | |
350 | } |
|
363 | } | |
351 | if (lowerSeries) { |
|
364 | if (lowerSeries) { | |
352 |
|
365 | |||
353 | const QList<QPointF>& points = lowerSeries->points(); |
|
366 | const QList<QPointF>& points = lowerSeries->points(); | |
354 |
|
367 | |||
355 | for (int i = 0; i < points.count(); i++) { |
|
368 | for (int i = 0; i < points.count(); i++) { | |
356 | qreal x = points[i].x(); |
|
369 | qreal x = points[i].x(); | |
357 | qreal y = points[i].y(); |
|
370 | qreal y = points[i].y(); | |
358 | minX = qMin(minX, x); |
|
371 | minX = qMin(minX, x); | |
359 | minY = qMin(minY, y); |
|
372 | minY = qMin(minY, y); | |
360 | maxX = qMax(maxX, x); |
|
373 | maxX = qMax(maxX, x); | |
361 | maxY = qMax(maxY, y); |
|
374 | maxY = qMax(maxY, y); | |
362 | } |
|
375 | } | |
363 | } |
|
376 | } | |
364 |
|
377 | |||
365 | domain()->setRange(minX, maxX, minY, maxY); |
|
378 | domain()->setRange(minX, maxX, minY, maxY); | |
366 | } |
|
379 | } | |
367 |
|
380 | |||
368 | void QAreaSeriesPrivate::initializeGraphics(QGraphicsItem* parent) |
|
381 | void QAreaSeriesPrivate::initializeGraphics(QGraphicsItem* parent) | |
369 | { |
|
382 | { | |
370 | Q_Q(QAreaSeries); |
|
383 | Q_Q(QAreaSeries); | |
371 | AreaChartItem *area = new AreaChartItem(q,parent); |
|
384 | AreaChartItem *area = new AreaChartItem(q,parent); | |
372 | m_item.reset(area); |
|
385 | m_item.reset(area); | |
373 | QAbstractSeriesPrivate::initializeGraphics(parent); |
|
386 | QAbstractSeriesPrivate::initializeGraphics(parent); | |
374 | } |
|
387 | } | |
375 | void QAreaSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
388 | void QAreaSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) | |
376 | { |
|
389 | { | |
377 | Q_Q(QAreaSeries); |
|
390 | Q_Q(QAreaSeries); | |
378 | AreaChartItem *area = static_cast<AreaChartItem *>(m_item.data()); |
|
391 | AreaChartItem *area = static_cast<AreaChartItem *>(m_item.data()); | |
379 | if (options.testFlag(QChart::SeriesAnimations)) { |
|
392 | if (options.testFlag(QChart::SeriesAnimations)) { | |
380 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); |
|
393 | area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem())); | |
381 | if (q->lowerSeries()) |
|
394 | if (q->lowerSeries()) | |
382 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); |
|
395 | area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem())); | |
383 | }else{ |
|
396 | }else{ | |
384 | area->upperLineItem()->setAnimation(0); |
|
397 | area->upperLineItem()->setAnimation(0); | |
385 | if (q->lowerSeries()) |
|
398 | if (q->lowerSeries()) | |
386 | area->lowerLineItem()->setAnimation(0); |
|
399 | area->lowerLineItem()->setAnimation(0); | |
387 | } |
|
400 | } | |
388 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
401 | QAbstractSeriesPrivate::initializeAnimations(options); | |
389 | } |
|
402 | } | |
390 |
|
403 | |||
391 | QList<QLegendMarker*> QAreaSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
404 | QList<QLegendMarker*> QAreaSeriesPrivate::createLegendMarkers(QLegend* legend) | |
392 | { |
|
405 | { | |
393 | Q_Q(QAreaSeries); |
|
406 | Q_Q(QAreaSeries); | |
394 | QList<QLegendMarker*> list; |
|
407 | QList<QLegendMarker*> list; | |
395 | return list << new QAreaLegendMarker(q,legend); |
|
408 | return list << new QAreaLegendMarker(q,legend); | |
396 | } |
|
409 | } | |
397 |
|
410 | |||
398 |
|
411 | |||
399 | void QAreaSeriesPrivate::initializeAxes() |
|
412 | void QAreaSeriesPrivate::initializeAxes() | |
400 | { |
|
413 | { | |
401 |
|
414 | |||
402 | } |
|
415 | } | |
403 |
|
416 | |||
404 | QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
417 | QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
405 | { |
|
418 | { | |
406 | Q_UNUSED(orientation); |
|
419 | Q_UNUSED(orientation); | |
407 | return QAbstractAxis::AxisTypeValue; |
|
420 | return QAbstractAxis::AxisTypeValue; | |
408 | } |
|
421 | } | |
409 |
|
422 | |||
410 | QAbstractAxis* QAreaSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
423 | QAbstractAxis* QAreaSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
411 | { |
|
424 | { | |
412 | Q_UNUSED(orientation); |
|
425 | Q_UNUSED(orientation); | |
413 | return 0; |
|
426 | return 0; | |
414 | } |
|
427 | } | |
415 |
|
428 | |||
416 | void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) |
|
429 | void QAreaSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
417 | { |
|
430 | { | |
418 | Q_Q(QAreaSeries); |
|
431 | Q_Q(QAreaSeries); | |
419 | QPen pen; |
|
432 | QPen pen; | |
420 | QBrush brush; |
|
433 | QBrush brush; | |
421 |
|
434 | |||
422 | const QList<QGradient> gradients = theme->seriesGradients(); |
|
435 | const QList<QGradient> gradients = theme->seriesGradients(); | |
423 | const QList<QColor> colors = theme->seriesColors(); |
|
436 | const QList<QColor> colors = theme->seriesColors(); | |
424 |
|
437 | |||
425 | if (forced || pen == m_pen) { |
|
438 | if (forced || pen == m_pen) { | |
426 | pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0)); |
|
439 | pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0)); | |
427 | pen.setWidthF(2); |
|
440 | pen.setWidthF(2); | |
428 | q->setPen(pen); |
|
441 | q->setPen(pen); | |
429 | } |
|
442 | } | |
430 |
|
443 | |||
431 | if (forced || brush == m_brush) { |
|
444 | if (forced || brush == m_brush) { | |
432 | QBrush brush(colors.at(index % colors.size())); |
|
445 | QBrush brush(colors.at(index % colors.size())); | |
433 | q->setBrush(brush); |
|
446 | q->setBrush(brush); | |
434 | } |
|
447 | } | |
435 | } |
|
448 | } | |
436 |
|
449 | |||
437 |
|
450 | |||
438 | #include "moc_qareaseries.cpp" |
|
451 | #include "moc_qareaseries.cpp" | |
439 | #include "moc_qareaseries_p.cpp" |
|
452 | #include "moc_qareaseries_p.cpp" | |
440 |
|
453 | |||
441 | QTCOMMERCIALCHART_END_NAMESPACE |
|
454 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,518 +1,531 | |||||
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 "qxyseries.h" |
|
21 | #include "qxyseries.h" | |
22 | #include "qxyseries_p.h" |
|
22 | #include "qxyseries_p.h" | |
23 | #include "abstractdomain_p.h" |
|
23 | #include "abstractdomain_p.h" | |
24 | #include "qvalueaxis.h" |
|
24 | #include "qvalueaxis.h" | |
25 | #include "xychart_p.h" |
|
25 | #include "xychart_p.h" | |
26 | #include "qxylegendmarker.h" |
|
26 | #include "qxylegendmarker.h" | |
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | /*! |
|
30 | /*! | |
31 | \class QXYSeries |
|
31 | \class QXYSeries | |
32 | \brief The QXYSeries class is a base class for line, spline and scatter series. |
|
32 | \brief The QXYSeries class is a base class for line, spline and scatter series. | |
33 | */ |
|
33 | */ | |
34 | /*! |
|
34 | /*! | |
35 | \qmlclass XYSeries |
|
35 | \qmlclass XYSeries | |
36 | \inherits AbstractSeries |
|
36 | \inherits AbstractSeries | |
37 | The XYSeries class is a base class for line, spline and scatter series. |
|
37 | The XYSeries class is a base class for line, spline and scatter series. | |
38 |
|
38 | |||
39 | The class cannot be instantiated directly. |
|
39 | The class cannot be instantiated directly. | |
40 | */ |
|
40 | */ | |
41 |
|
41 | |||
42 | /*! |
|
42 | /*! | |
43 | \qmlproperty AbstractAxis XYSeries::axisX |
|
43 | \qmlproperty AbstractAxis XYSeries::axisX | |
44 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for |
|
44 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a ValueAxis is created for | |
45 | the series. |
|
45 | the series. | |
46 | \sa axisXTop |
|
46 | \sa axisXTop | |
47 | */ |
|
47 | */ | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \qmlproperty AbstractAxis XYSeries::axisY |
|
50 | \qmlproperty AbstractAxis XYSeries::axisY | |
51 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for |
|
51 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for | |
52 | the series. |
|
52 | the series. | |
53 | \sa axisYRight |
|
53 | \sa axisYRight | |
54 | */ |
|
54 | */ | |
55 |
|
55 | |||
56 | /*! |
|
56 | /*! | |
57 | \qmlproperty AbstractAxis XYSeries::axisXTop |
|
57 | \qmlproperty AbstractAxis XYSeries::axisXTop | |
58 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or |
|
58 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or | |
59 | axisXTop, but not both. |
|
59 | axisXTop, but not both. | |
60 | \sa axisX |
|
60 | \sa axisX | |
61 | */ |
|
61 | */ | |
62 |
|
62 | |||
63 | /*! |
|
63 | /*! | |
64 | \qmlproperty AbstractAxis XYSeries::axisYRight |
|
64 | \qmlproperty AbstractAxis XYSeries::axisYRight | |
65 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY |
|
65 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY | |
66 | or axisYRight, but not both. |
|
66 | or axisYRight, but not both. | |
67 | \sa axisY |
|
67 | \sa axisY | |
68 | */ |
|
68 | */ | |
69 |
|
69 | |||
70 | /*! |
|
70 | /*! | |
71 | \property QXYSeries::pointsVisible |
|
71 | \property QXYSeries::pointsVisible | |
72 | Controls if the data points are visible and should be drawn. |
|
72 | Controls if the data points are visible and should be drawn. | |
73 | */ |
|
73 | */ | |
74 | /*! |
|
74 | /*! | |
75 | \qmlproperty bool XYSeries::pointsVisible |
|
75 | \qmlproperty bool XYSeries::pointsVisible | |
76 | Controls if the data points are visible and should be drawn. |
|
76 | Controls if the data points are visible and should be drawn. | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \fn QPen QXYSeries::pen() const |
|
80 | \fn QPen QXYSeries::pen() const | |
81 | \brief Returns pen used to draw points for series. |
|
81 | \brief Returns pen used to draw points for series. | |
82 | \sa setPen() |
|
82 | \sa setPen() | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | /*! |
|
85 | /*! | |
86 | \fn QBrush QXYSeries::brush() const |
|
86 | \fn QBrush QXYSeries::brush() const | |
87 | \brief Returns brush used to draw points for series. |
|
87 | \brief Returns brush used to draw points for series. | |
88 | \sa setBrush() |
|
88 | \sa setBrush() | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \property QXYSeries::color |
|
92 | \property QXYSeries::color | |
93 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and |
|
93 | The color of the series. This is line (pen) color in case of QLineSeries or QSplineSeries and | |
94 | fill (brush) color in case of QScatterSeries or QAreaSeries. |
|
94 | fill (brush) color in case of QScatterSeries or QAreaSeries. | |
95 | \sa QXYSeries::pen(), QXYSeries::brush() |
|
95 | \sa QXYSeries::pen(), QXYSeries::brush() | |
96 | */ |
|
96 | */ | |
97 | /*! |
|
97 | /*! | |
98 | \qmlproperty color XYSeries::color |
|
98 | \qmlproperty color XYSeries::color | |
99 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and |
|
99 | The color of the series. This is line (pen) color in case of LineSeries or SplineSeries and | |
100 | fill (brush) color in case of ScatterSeries or AreaSeries. |
|
100 | fill (brush) color in case of ScatterSeries or AreaSeries. | |
101 | */ |
|
101 | */ | |
102 |
|
102 | |||
103 | /*! |
|
103 | /*! | |
104 | \fn void QXYSeries::clicked(const QPointF& point) |
|
104 | \fn void QXYSeries::clicked(const QPointF& point) | |
105 | \brief Signal is emitted when user clicks the \a point on chart. |
|
105 | \brief Signal is emitted when user clicks the \a point on chart. | |
106 | */ |
|
106 | */ | |
107 | /*! |
|
107 | /*! | |
108 | \qmlsignal XYSeries::onClicked(QPointF point) |
|
108 | \qmlsignal XYSeries::onClicked(QPointF point) | |
109 | Signal is emitted when user clicks the \a point on chart. For example: |
|
109 | Signal is emitted when user clicks the \a point on chart. For example: | |
110 | \code |
|
110 | \code | |
111 | LineSeries { |
|
111 | LineSeries { | |
112 | XYPoint { x: 0; y: 0 } |
|
112 | XYPoint { x: 0; y: 0 } | |
113 | XYPoint { x: 1.1; y: 2.1 } |
|
113 | XYPoint { x: 1.1; y: 2.1 } | |
114 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); |
|
114 | onClicked: console.log("onClicked: " + point.x + ", " + point.y); | |
115 | } |
|
115 | } | |
116 | \endcode |
|
116 | \endcode | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
|
120 | \fn void QXYSeries::hovered(const QPointF &point, bool state) | |||
|
121 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |||
|
122 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |||
|
123 | the series. | |||
|
124 | */ | |||
|
125 | /*! | |||
|
126 | \qmlsignal XYSeries::onHovered(point point, bool state) | |||
|
127 | This signal is emitted when user has hovered over or away from the series. \a point shows the origin (coordinate) | |||
|
128 | of the hover event. \a state is true when user has hovered over the series and false when hover has moved away from | |||
|
129 | the series. | |||
|
130 | */ | |||
|
131 | ||||
|
132 | /*! | |||
120 | \fn void QXYSeries::pointReplaced(int index) |
|
133 | \fn void QXYSeries::pointReplaced(int index) | |
121 | Signal is emitted when a point has been replaced at \a index. |
|
134 | Signal is emitted when a point has been replaced at \a index. | |
122 | \sa replace() |
|
135 | \sa replace() | |
123 | */ |
|
136 | */ | |
124 | /*! |
|
137 | /*! | |
125 | \qmlsignal XYSeries::onPointReplaced(int index) |
|
138 | \qmlsignal XYSeries::onPointReplaced(int index) | |
126 | Signal is emitted when a point has been replaced at \a index. |
|
139 | Signal is emitted when a point has been replaced at \a index. | |
127 | */ |
|
140 | */ | |
128 |
|
141 | |||
129 | /*! |
|
142 | /*! | |
130 | \fn void QXYSeries::pointsReplaced() |
|
143 | \fn void QXYSeries::pointsReplaced() | |
131 | Signal is emitted when all points have been replaced with another points. |
|
144 | Signal is emitted when all points have been replaced with another points. | |
132 | \sa replace() |
|
145 | \sa replace() | |
133 | */ |
|
146 | */ | |
134 | /*! |
|
147 | /*! | |
135 | \qmlsignal XYSeries::onPointsReplaced() |
|
148 | \qmlsignal XYSeries::onPointsReplaced() | |
136 | */ |
|
149 | */ | |
137 |
|
150 | |||
138 | /*! |
|
151 | /*! | |
139 | \fn void QXYSeries::pointAdded(int index) |
|
152 | \fn void QXYSeries::pointAdded(int index) | |
140 | Signal is emitted when a point has been added at \a index. |
|
153 | Signal is emitted when a point has been added at \a index. | |
141 | \sa append(), insert() |
|
154 | \sa append(), insert() | |
142 | */ |
|
155 | */ | |
143 | /*! |
|
156 | /*! | |
144 | \qmlsignal XYSeries::onPointAdded(int index) |
|
157 | \qmlsignal XYSeries::onPointAdded(int index) | |
145 | Signal is emitted when a point has been added at \a index. |
|
158 | Signal is emitted when a point has been added at \a index. | |
146 | */ |
|
159 | */ | |
147 |
|
160 | |||
148 | /*! |
|
161 | /*! | |
149 | \fn void QXYSeries::pointRemoved(int index) |
|
162 | \fn void QXYSeries::pointRemoved(int index) | |
150 | Signal is emitted when a point has been removed from \a index. |
|
163 | Signal is emitted when a point has been removed from \a index. | |
151 | \sa remove() |
|
164 | \sa remove() | |
152 | */ |
|
165 | */ | |
153 | /*! |
|
166 | /*! | |
154 | \qmlsignal XYSeries::onPointRemoved(int index) |
|
167 | \qmlsignal XYSeries::onPointRemoved(int index) | |
155 | Signal is emitted when a point has been removed from \a index. |
|
168 | Signal is emitted when a point has been removed from \a index. | |
156 | */ |
|
169 | */ | |
157 |
|
170 | |||
158 | /*! |
|
171 | /*! | |
159 | \fn void QXYSeries::colorChanged(QColor color) |
|
172 | \fn void QXYSeries::colorChanged(QColor color) | |
160 | \brief Signal is emitted when the line (pen) color has changed to \a color. |
|
173 | \brief Signal is emitted when the line (pen) color has changed to \a color. | |
161 | */ |
|
174 | */ | |
162 | /*! |
|
175 | /*! | |
163 | \qmlsignal XYSeries::onColorChanged(color color) |
|
176 | \qmlsignal XYSeries::onColorChanged(color color) | |
164 | Signal is emitted when the line (pen) color has changed to \a color. |
|
177 | Signal is emitted when the line (pen) color has changed to \a color. | |
165 | */ |
|
178 | */ | |
166 |
|
179 | |||
167 | /*! |
|
180 | /*! | |
168 | \fn void QXYSeriesPrivate::updated() |
|
181 | \fn void QXYSeriesPrivate::updated() | |
169 | \brief \internal |
|
182 | \brief \internal | |
170 | */ |
|
183 | */ | |
171 |
|
184 | |||
172 | /*! |
|
185 | /*! | |
173 | \qmlmethod XYSeries::append(real x, real y) |
|
186 | \qmlmethod XYSeries::append(real x, real y) | |
174 | Append point (\a x, \a y) to the series |
|
187 | Append point (\a x, \a y) to the series | |
175 | */ |
|
188 | */ | |
176 |
|
189 | |||
177 | /*! |
|
190 | /*! | |
178 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) |
|
191 | \qmlmethod XYSeries::replace(real oldX, real oldY, real newX, real newY) | |
179 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not |
|
192 | Replaces point (\a oldX, \a oldY) with point (\a newX, \a newY). Does nothing, if point (oldX, oldY) does not | |
180 | exist. |
|
193 | exist. | |
181 | */ |
|
194 | */ | |
182 |
|
195 | |||
183 | /*! |
|
196 | /*! | |
184 | \qmlmethod XYSeries::remove(real x, real y) |
|
197 | \qmlmethod XYSeries::remove(real x, real y) | |
185 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. |
|
198 | Removes point (\a x, \a y) from the series. Does nothing, if point (x, y) does not exist. | |
186 | */ |
|
199 | */ | |
187 |
|
200 | |||
188 | /*! |
|
201 | /*! | |
189 | \qmlmethod XYSeries::insert(int index, real x, real y) |
|
202 | \qmlmethod XYSeries::insert(int index, real x, real y) | |
190 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of |
|
203 | Inserts point (\a x, \a y) to the \a index. If index is 0 or smaller than 0 the point is prepended to the list of | |
191 | points. If index is the same as or bigger than count, the point is appended to the list of points. |
|
204 | points. If index is the same as or bigger than count, the point is appended to the list of points. | |
192 | */ |
|
205 | */ | |
193 |
|
206 | |||
194 | /*! |
|
207 | /*! | |
195 | \qmlmethod QPointF XYSeries::at(int index) |
|
208 | \qmlmethod QPointF XYSeries::at(int index) | |
196 | Returns point at \a index. Returns (0, 0) if the index is not valid. |
|
209 | Returns point at \a index. Returns (0, 0) if the index is not valid. | |
197 | */ |
|
210 | */ | |
198 |
|
211 | |||
199 | /*! |
|
212 | /*! | |
200 | \internal |
|
213 | \internal | |
201 |
|
214 | |||
202 | Constructs empty series object which is a child of \a parent. |
|
215 | Constructs empty series object which is a child of \a parent. | |
203 | When series object is added to QChartView or QChart instance ownerships is transferred. |
|
216 | When series object is added to QChartView or QChart instance ownerships is transferred. | |
204 | */ |
|
217 | */ | |
205 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) |
|
218 | QXYSeries::QXYSeries(QXYSeriesPrivate &d, QObject *parent) | |
206 | : QAbstractSeries(d, parent) |
|
219 | : QAbstractSeries(d, parent) | |
207 | { |
|
220 | { | |
208 | } |
|
221 | } | |
209 |
|
222 | |||
210 | /*! |
|
223 | /*! | |
211 | Destroys the object. Series added to QChartView or QChart instances are owned by those, |
|
224 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | |
212 | and are deleted when mentioned object are destroyed. |
|
225 | and are deleted when mentioned object are destroyed. | |
213 | */ |
|
226 | */ | |
214 | QXYSeries::~QXYSeries() |
|
227 | QXYSeries::~QXYSeries() | |
215 | { |
|
228 | { | |
216 | } |
|
229 | } | |
217 |
|
230 | |||
218 | /*! |
|
231 | /*! | |
219 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. |
|
232 | Adds data point \a x \a y to the series. Points are connected with lines on the chart. | |
220 | */ |
|
233 | */ | |
221 | void QXYSeries::append(qreal x, qreal y) |
|
234 | void QXYSeries::append(qreal x, qreal y) | |
222 | { |
|
235 | { | |
223 | append(QPointF(x, y)); |
|
236 | append(QPointF(x, y)); | |
224 | } |
|
237 | } | |
225 |
|
238 | |||
226 | /*! |
|
239 | /*! | |
227 | This is an overloaded function. |
|
240 | This is an overloaded function. | |
228 | Adds data \a point to the series. Points are connected with lines on the chart. |
|
241 | Adds data \a point to the series. Points are connected with lines on the chart. | |
229 | */ |
|
242 | */ | |
230 | void QXYSeries::append(const QPointF &point) |
|
243 | void QXYSeries::append(const QPointF &point) | |
231 | { |
|
244 | { | |
232 | Q_D(QXYSeries); |
|
245 | Q_D(QXYSeries); | |
233 | d->m_points << point; |
|
246 | d->m_points << point; | |
234 | emit pointAdded(d->m_points.count() - 1); |
|
247 | emit pointAdded(d->m_points.count() - 1); | |
235 | } |
|
248 | } | |
236 |
|
249 | |||
237 | /*! |
|
250 | /*! | |
238 | This is an overloaded function. |
|
251 | This is an overloaded function. | |
239 | Adds list of data \a points to the series. Points are connected with lines on the chart. |
|
252 | Adds list of data \a points to the series. Points are connected with lines on the chart. | |
240 | */ |
|
253 | */ | |
241 | void QXYSeries::append(const QList<QPointF> &points) |
|
254 | void QXYSeries::append(const QList<QPointF> &points) | |
242 | { |
|
255 | { | |
243 | foreach (const QPointF &point , points) |
|
256 | foreach (const QPointF &point , points) | |
244 | append(point); |
|
257 | append(point); | |
245 | } |
|
258 | } | |
246 |
|
259 | |||
247 | /*! |
|
260 | /*! | |
248 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. |
|
261 | Replaces data point \a oldX \a oldY with data point \a newX \a newY. | |
249 | \sa QXYSeries::pointReplaced() |
|
262 | \sa QXYSeries::pointReplaced() | |
250 | */ |
|
263 | */ | |
251 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
|
264 | void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY) | |
252 | { |
|
265 | { | |
253 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); |
|
266 | replace(QPointF(oldX, oldY), QPointF(newX, newY)); | |
254 | } |
|
267 | } | |
255 |
|
268 | |||
256 | /*! |
|
269 | /*! | |
257 | Replaces \a oldPoint with \a newPoint. |
|
270 | Replaces \a oldPoint with \a newPoint. | |
258 | \sa QXYSeries::pointReplaced() |
|
271 | \sa QXYSeries::pointReplaced() | |
259 | */ |
|
272 | */ | |
260 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) |
|
273 | void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint) | |
261 | { |
|
274 | { | |
262 | Q_D(QXYSeries); |
|
275 | Q_D(QXYSeries); | |
263 | int index = d->m_points.indexOf(oldPoint); |
|
276 | int index = d->m_points.indexOf(oldPoint); | |
264 | if (index == -1) |
|
277 | if (index == -1) | |
265 | return; |
|
278 | return; | |
266 | d->m_points[index] = newPoint; |
|
279 | d->m_points[index] = newPoint; | |
267 | emit pointReplaced(index); |
|
280 | emit pointReplaced(index); | |
268 | } |
|
281 | } | |
269 |
|
282 | |||
270 | /*! |
|
283 | /*! | |
271 | Replaces the current points with \a points. This is faster than replacing data points one by one, |
|
284 | Replaces the current points with \a points. This is faster than replacing data points one by one, | |
272 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() |
|
285 | or first clearing all data, and then appending the new data. Emits QXYSeries::pointsReplaced() | |
273 | when the points have been replaced. |
|
286 | when the points have been replaced. | |
274 | \sa QXYSeries::pointsReplaced() |
|
287 | \sa QXYSeries::pointsReplaced() | |
275 | */ |
|
288 | */ | |
276 | void QXYSeries::replace(QList<QPointF> points) |
|
289 | void QXYSeries::replace(QList<QPointF> points) | |
277 | { |
|
290 | { | |
278 | Q_D(QXYSeries); |
|
291 | Q_D(QXYSeries); | |
279 | d->m_points = points.toVector(); |
|
292 | d->m_points = points.toVector(); | |
280 | emit pointsReplaced(); |
|
293 | emit pointsReplaced(); | |
281 | } |
|
294 | } | |
282 |
|
295 | |||
283 | /*! |
|
296 | /*! | |
284 | Removes current \a x and \a y value. |
|
297 | Removes current \a x and \a y value. | |
285 | */ |
|
298 | */ | |
286 | void QXYSeries::remove(qreal x, qreal y) |
|
299 | void QXYSeries::remove(qreal x, qreal y) | |
287 | { |
|
300 | { | |
288 | remove(QPointF(x, y)); |
|
301 | remove(QPointF(x, y)); | |
289 | } |
|
302 | } | |
290 |
|
303 | |||
291 | /*! |
|
304 | /*! | |
292 | Removes current \a point x value. |
|
305 | Removes current \a point x value. | |
293 |
|
306 | |||
294 | Note: point y value is ignored. |
|
307 | Note: point y value is ignored. | |
295 | */ |
|
308 | */ | |
296 | void QXYSeries::remove(const QPointF &point) |
|
309 | void QXYSeries::remove(const QPointF &point) | |
297 | { |
|
310 | { | |
298 | Q_D(QXYSeries); |
|
311 | Q_D(QXYSeries); | |
299 | int index = d->m_points.indexOf(point); |
|
312 | int index = d->m_points.indexOf(point); | |
300 | if (index == -1) |
|
313 | if (index == -1) | |
301 | return; |
|
314 | return; | |
302 | d->m_points.remove(index); |
|
315 | d->m_points.remove(index); | |
303 | emit pointRemoved(index); |
|
316 | emit pointRemoved(index); | |
304 | } |
|
317 | } | |
305 |
|
318 | |||
306 | /*! |
|
319 | /*! | |
307 | Inserts a \a point in the series at \a index position. |
|
320 | Inserts a \a point in the series at \a index position. | |
308 | */ |
|
321 | */ | |
309 | void QXYSeries::insert(int index, const QPointF &point) |
|
322 | void QXYSeries::insert(int index, const QPointF &point) | |
310 | { |
|
323 | { | |
311 | Q_D(QXYSeries); |
|
324 | Q_D(QXYSeries); | |
312 | d->m_points.insert(index, point); |
|
325 | d->m_points.insert(index, point); | |
313 | emit pointAdded(index); |
|
326 | emit pointAdded(index); | |
314 | } |
|
327 | } | |
315 |
|
328 | |||
316 | /*! |
|
329 | /*! | |
317 | Removes all points from the series. |
|
330 | Removes all points from the series. | |
318 | */ |
|
331 | */ | |
319 | void QXYSeries::clear() |
|
332 | void QXYSeries::clear() | |
320 | { |
|
333 | { | |
321 | Q_D(QXYSeries); |
|
334 | Q_D(QXYSeries); | |
322 | for (int i = d->m_points.size() - 1; i >= 0; i--) |
|
335 | for (int i = d->m_points.size() - 1; i >= 0; i--) | |
323 | remove(d->m_points.at(i)); |
|
336 | remove(d->m_points.at(i)); | |
324 | } |
|
337 | } | |
325 |
|
338 | |||
326 | /*! |
|
339 | /*! | |
327 | Returns list of points in the series. |
|
340 | Returns list of points in the series. | |
328 | */ |
|
341 | */ | |
329 | QList<QPointF> QXYSeries::points() const |
|
342 | QList<QPointF> QXYSeries::points() const | |
330 | { |
|
343 | { | |
331 | Q_D(const QXYSeries); |
|
344 | Q_D(const QXYSeries); | |
332 | return d->m_points.toList(); |
|
345 | return d->m_points.toList(); | |
333 | } |
|
346 | } | |
334 |
|
347 | |||
335 | /*! |
|
348 | /*! | |
336 | Returns number of data points within series. |
|
349 | Returns number of data points within series. | |
337 | */ |
|
350 | */ | |
338 | int QXYSeries::count() const |
|
351 | int QXYSeries::count() const | |
339 | { |
|
352 | { | |
340 | Q_D(const QXYSeries); |
|
353 | Q_D(const QXYSeries); | |
341 | return d->m_points.count(); |
|
354 | return d->m_points.count(); | |
342 | } |
|
355 | } | |
343 |
|
356 | |||
344 |
|
357 | |||
345 | /*! |
|
358 | /*! | |
346 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the |
|
359 | Sets \a pen used for drawing points on the chart. If the pen is not defined, the | |
347 | pen from chart theme is used. |
|
360 | pen from chart theme is used. | |
348 | \sa QChart::setTheme() |
|
361 | \sa QChart::setTheme() | |
349 | */ |
|
362 | */ | |
350 | void QXYSeries::setPen(const QPen &pen) |
|
363 | void QXYSeries::setPen(const QPen &pen) | |
351 | { |
|
364 | { | |
352 | Q_D(QXYSeries); |
|
365 | Q_D(QXYSeries); | |
353 | if (d->m_pen != pen) { |
|
366 | if (d->m_pen != pen) { | |
354 | bool emitColorChanged = d->m_pen.color() != pen.color(); |
|
367 | bool emitColorChanged = d->m_pen.color() != pen.color(); | |
355 | d->m_pen = pen; |
|
368 | d->m_pen = pen; | |
356 | emit d->updated(); |
|
369 | emit d->updated(); | |
357 | if (emitColorChanged) |
|
370 | if (emitColorChanged) | |
358 | emit colorChanged(pen.color()); |
|
371 | emit colorChanged(pen.color()); | |
359 | } |
|
372 | } | |
360 | } |
|
373 | } | |
361 |
|
374 | |||
362 | QPen QXYSeries::pen() const |
|
375 | QPen QXYSeries::pen() const | |
363 | { |
|
376 | { | |
364 | Q_D(const QXYSeries); |
|
377 | Q_D(const QXYSeries); | |
365 | return d->m_pen; |
|
378 | return d->m_pen; | |
366 | } |
|
379 | } | |
367 |
|
380 | |||
368 | /*! |
|
381 | /*! | |
369 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush |
|
382 | Sets \a brush used for drawing points on the chart. If the brush is not defined, brush | |
370 | from chart theme setting is used. |
|
383 | from chart theme setting is used. | |
371 | \sa QChart::setTheme() |
|
384 | \sa QChart::setTheme() | |
372 | */ |
|
385 | */ | |
373 | void QXYSeries::setBrush(const QBrush &brush) |
|
386 | void QXYSeries::setBrush(const QBrush &brush) | |
374 | { |
|
387 | { | |
375 | Q_D(QXYSeries); |
|
388 | Q_D(QXYSeries); | |
376 | if (d->m_brush != brush) { |
|
389 | if (d->m_brush != brush) { | |
377 | d->m_brush = brush; |
|
390 | d->m_brush = brush; | |
378 | emit d->updated(); |
|
391 | emit d->updated(); | |
379 | } |
|
392 | } | |
380 | } |
|
393 | } | |
381 |
|
394 | |||
382 | QBrush QXYSeries::brush() const |
|
395 | QBrush QXYSeries::brush() const | |
383 | { |
|
396 | { | |
384 | Q_D(const QXYSeries); |
|
397 | Q_D(const QXYSeries); | |
385 | return d->m_brush; |
|
398 | return d->m_brush; | |
386 | } |
|
399 | } | |
387 |
|
400 | |||
388 | void QXYSeries::setColor(const QColor &color) |
|
401 | void QXYSeries::setColor(const QColor &color) | |
389 | { |
|
402 | { | |
390 | QPen p = pen(); |
|
403 | QPen p = pen(); | |
391 | if (p.color() != color) { |
|
404 | if (p.color() != color) { | |
392 | p.setColor(color); |
|
405 | p.setColor(color); | |
393 | setPen(p); |
|
406 | setPen(p); | |
394 | } |
|
407 | } | |
395 | } |
|
408 | } | |
396 |
|
409 | |||
397 | QColor QXYSeries::color() const |
|
410 | QColor QXYSeries::color() const | |
398 | { |
|
411 | { | |
399 | return pen().color(); |
|
412 | return pen().color(); | |
400 | } |
|
413 | } | |
401 |
|
414 | |||
402 | void QXYSeries::setPointsVisible(bool visible) |
|
415 | void QXYSeries::setPointsVisible(bool visible) | |
403 | { |
|
416 | { | |
404 | Q_D(QXYSeries); |
|
417 | Q_D(QXYSeries); | |
405 | if (d->m_pointsVisible != visible) { |
|
418 | if (d->m_pointsVisible != visible) { | |
406 | d->m_pointsVisible = visible; |
|
419 | d->m_pointsVisible = visible; | |
407 | emit d->updated(); |
|
420 | emit d->updated(); | |
408 | } |
|
421 | } | |
409 | } |
|
422 | } | |
410 |
|
423 | |||
411 | bool QXYSeries::pointsVisible() const |
|
424 | bool QXYSeries::pointsVisible() const | |
412 | { |
|
425 | { | |
413 | Q_D(const QXYSeries); |
|
426 | Q_D(const QXYSeries); | |
414 | return d->m_pointsVisible; |
|
427 | return d->m_pointsVisible; | |
415 | } |
|
428 | } | |
416 |
|
429 | |||
417 |
|
430 | |||
418 | /*! |
|
431 | /*! | |
419 | Stream operator for adding a data \a point to the series. |
|
432 | Stream operator for adding a data \a point to the series. | |
420 | \sa append() |
|
433 | \sa append() | |
421 | */ |
|
434 | */ | |
422 | QXYSeries &QXYSeries::operator<< (const QPointF &point) |
|
435 | QXYSeries &QXYSeries::operator<< (const QPointF &point) | |
423 | { |
|
436 | { | |
424 | append(point); |
|
437 | append(point); | |
425 | return *this; |
|
438 | return *this; | |
426 | } |
|
439 | } | |
427 |
|
440 | |||
428 |
|
441 | |||
429 | /*! |
|
442 | /*! | |
430 | Stream operator for adding a list of \a points to the series. |
|
443 | Stream operator for adding a list of \a points to the series. | |
431 | \sa append() |
|
444 | \sa append() | |
432 | */ |
|
445 | */ | |
433 |
|
446 | |||
434 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) |
|
447 | QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points) | |
435 | { |
|
448 | { | |
436 | append(points); |
|
449 | append(points); | |
437 | return *this; |
|
450 | return *this; | |
438 | } |
|
451 | } | |
439 |
|
452 | |||
440 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
453 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
441 |
|
454 | |||
442 |
|
455 | |||
443 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) |
|
456 | QXYSeriesPrivate::QXYSeriesPrivate(QXYSeries *q) | |
444 | : QAbstractSeriesPrivate(q), |
|
457 | : QAbstractSeriesPrivate(q), | |
445 | m_pointsVisible(false) |
|
458 | m_pointsVisible(false) | |
446 | { |
|
459 | { | |
447 | } |
|
460 | } | |
448 |
|
461 | |||
449 | void QXYSeriesPrivate::initializeDomain() |
|
462 | void QXYSeriesPrivate::initializeDomain() | |
450 | { |
|
463 | { | |
451 | qreal minX(0); |
|
464 | qreal minX(0); | |
452 | qreal minY(0); |
|
465 | qreal minY(0); | |
453 | qreal maxX(1); |
|
466 | qreal maxX(1); | |
454 | qreal maxY(1); |
|
467 | qreal maxY(1); | |
455 |
|
468 | |||
456 | Q_Q(QXYSeries); |
|
469 | Q_Q(QXYSeries); | |
457 |
|
470 | |||
458 | const QList<QPointF>& points = q->points(); |
|
471 | const QList<QPointF>& points = q->points(); | |
459 |
|
472 | |||
460 | if (!points.isEmpty()) { |
|
473 | if (!points.isEmpty()) { | |
461 | minX = points[0].x(); |
|
474 | minX = points[0].x(); | |
462 | minY = points[0].y(); |
|
475 | minY = points[0].y(); | |
463 | maxX = minX; |
|
476 | maxX = minX; | |
464 | maxY = minY; |
|
477 | maxY = minY; | |
465 |
|
478 | |||
466 | for (int i = 0; i < points.count(); i++) { |
|
479 | for (int i = 0; i < points.count(); i++) { | |
467 | qreal x = points[i].x(); |
|
480 | qreal x = points[i].x(); | |
468 | qreal y = points[i].y(); |
|
481 | qreal y = points[i].y(); | |
469 | minX = qMin(minX, x); |
|
482 | minX = qMin(minX, x); | |
470 | minY = qMin(minY, y); |
|
483 | minY = qMin(minY, y); | |
471 | maxX = qMax(maxX, x); |
|
484 | maxX = qMax(maxX, x); | |
472 | maxY = qMax(maxY, y); |
|
485 | maxY = qMax(maxY, y); | |
473 | } |
|
486 | } | |
474 | } |
|
487 | } | |
475 |
|
488 | |||
476 | domain()->setRange(minX, maxX, minY, maxY); |
|
489 | domain()->setRange(minX, maxX, minY, maxY); | |
477 | } |
|
490 | } | |
478 |
|
491 | |||
479 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) |
|
492 | QList<QLegendMarker*> QXYSeriesPrivate::createLegendMarkers(QLegend* legend) | |
480 | { |
|
493 | { | |
481 | Q_Q(QXYSeries); |
|
494 | Q_Q(QXYSeries); | |
482 | QList<QLegendMarker*> list; |
|
495 | QList<QLegendMarker*> list; | |
483 | return list << new QXYLegendMarker(q,legend); |
|
496 | return list << new QXYLegendMarker(q,legend); | |
484 | } |
|
497 | } | |
485 |
|
498 | |||
486 | void QXYSeriesPrivate::initializeAxes() |
|
499 | void QXYSeriesPrivate::initializeAxes() | |
487 | { |
|
500 | { | |
488 |
|
501 | |||
489 | } |
|
502 | } | |
490 |
|
503 | |||
491 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const |
|
504 | QAbstractAxis::AxisType QXYSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const | |
492 | { |
|
505 | { | |
493 | Q_UNUSED(orientation); |
|
506 | Q_UNUSED(orientation); | |
494 | return QAbstractAxis::AxisTypeValue; |
|
507 | return QAbstractAxis::AxisTypeValue; | |
495 | } |
|
508 | } | |
496 |
|
509 | |||
497 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const |
|
510 | QAbstractAxis* QXYSeriesPrivate::createDefaultAxis(Qt::Orientation orientation) const | |
498 | { |
|
511 | { | |
499 | Q_UNUSED(orientation); |
|
512 | Q_UNUSED(orientation); | |
500 | return 0; |
|
513 | return 0; | |
501 | } |
|
514 | } | |
502 |
|
515 | |||
503 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) |
|
516 | void QXYSeriesPrivate::initializeAnimations(QtCommercialChart::QChart::AnimationOptions options) | |
504 | { |
|
517 | { | |
505 | XYChart *item = static_cast<XYChart *>(m_item.data()); |
|
518 | XYChart *item = static_cast<XYChart *>(m_item.data()); | |
506 | Q_ASSERT(item); |
|
519 | Q_ASSERT(item); | |
507 | if (options.testFlag(QChart::SeriesAnimations)) { |
|
520 | if (options.testFlag(QChart::SeriesAnimations)) { | |
508 | item->setAnimation(new XYAnimation(item)); |
|
521 | item->setAnimation(new XYAnimation(item)); | |
509 | }else{ |
|
522 | }else{ | |
510 | item->setAnimation(0); |
|
523 | item->setAnimation(0); | |
511 | } |
|
524 | } | |
512 | QAbstractSeriesPrivate::initializeAnimations(options); |
|
525 | QAbstractSeriesPrivate::initializeAnimations(options); | |
513 | } |
|
526 | } | |
514 |
|
527 | |||
515 | #include "moc_qxyseries.cpp" |
|
528 | #include "moc_qxyseries.cpp" | |
516 | #include "moc_qxyseries_p.cpp" |
|
529 | #include "moc_qxyseries_p.cpp" | |
517 |
|
530 | |||
518 | QTCOMMERCIALCHART_END_NAMESPACE |
|
531 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,100 +1,101 | |||||
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 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.1 |
|
22 | import QtCommercial.Chart 1.1 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | title: "area series" |
|
25 | title: "area series" | |
26 | anchors.fill: parent |
|
26 | anchors.fill: parent | |
27 | animationOptions: ChartView.SeriesAnimations |
|
27 | animationOptions: ChartView.SeriesAnimations | |
28 |
|
28 | |||
29 | property variant series: areaSeries |
|
29 | property variant series: areaSeries | |
30 |
|
30 | |||
31 | AreaSeries { |
|
31 | AreaSeries { | |
32 | id: areaSeries |
|
32 | id: areaSeries | |
33 | name: "area 1" |
|
33 | name: "area 1" | |
34 |
|
34 | |||
35 | upperSeries: LineSeries { |
|
35 | upperSeries: LineSeries { | |
36 | XYPoint { x: 0; y: 1 } |
|
36 | XYPoint { x: 0; y: 1 } | |
37 | XYPoint { x: 1; y: 1 } |
|
37 | XYPoint { x: 1; y: 1 } | |
38 | XYPoint { x: 2; y: 3 } |
|
38 | XYPoint { x: 2; y: 3 } | |
39 | XYPoint { x: 3; y: 3 } |
|
39 | XYPoint { x: 3; y: 3 } | |
40 | XYPoint { x: 4; y: 2 } |
|
40 | XYPoint { x: 4; y: 2 } | |
41 | XYPoint { x: 5; y: 0 } |
|
41 | XYPoint { x: 5; y: 0 } | |
42 | XYPoint { x: 6; y: 2 } |
|
42 | XYPoint { x: 6; y: 2 } | |
43 | XYPoint { x: 7; y: 1 } |
|
43 | XYPoint { x: 7; y: 1 } | |
44 | XYPoint { x: 8; y: 2 } |
|
44 | XYPoint { x: 8; y: 2 } | |
45 | XYPoint { x: 9; y: 1 } |
|
45 | XYPoint { x: 9; y: 1 } | |
46 | XYPoint { x: 10; y: 3 } |
|
46 | XYPoint { x: 10; y: 3 } | |
47 | XYPoint { x: 11; y: 3 } |
|
47 | XYPoint { x: 11; y: 3 } | |
48 | } |
|
48 | } | |
49 | lowerSeries: LineSeries { |
|
49 | lowerSeries: LineSeries { | |
50 | XYPoint { x: 0; y: 0 } |
|
50 | XYPoint { x: 0; y: 0 } | |
51 | XYPoint { x: 1; y: 0 } |
|
51 | XYPoint { x: 1; y: 0 } | |
52 | XYPoint { x: 2; y: 0 } |
|
52 | XYPoint { x: 2; y: 0 } | |
53 | XYPoint { x: 3; y: 0 } |
|
53 | XYPoint { x: 3; y: 0 } | |
54 | XYPoint { x: 4; y: 0 } |
|
54 | XYPoint { x: 4; y: 0 } | |
55 | XYPoint { x: 5; y: 0 } |
|
55 | XYPoint { x: 5; y: 0 } | |
56 | XYPoint { x: 6; y: 0 } |
|
56 | XYPoint { x: 6; y: 0 } | |
57 | XYPoint { x: 7; y: 0 } |
|
57 | XYPoint { x: 7; y: 0 } | |
58 | XYPoint { x: 8; y: 0 } |
|
58 | XYPoint { x: 8; y: 0 } | |
59 | XYPoint { x: 9; y: 0 } |
|
59 | XYPoint { x: 9; y: 0 } | |
60 | XYPoint { x: 10; y: 0 } |
|
60 | XYPoint { x: 10; y: 0 } | |
61 | XYPoint { x: 11; y: 0 } |
|
61 | XYPoint { x: 11; y: 0 } | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | onNameChanged: console.log(name + ".onNameChanged: " + name); |
|
64 | onNameChanged: console.log(name + ".onNameChanged: " + name); | |
65 | onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); |
|
65 | onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); | |
66 | onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity); |
|
66 | onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity); | |
67 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
67 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
68 | onSelected: console.log(name + ".onSelected"); |
|
68 | onSelected: console.log(name + ".onSelected"); | |
69 | onColorChanged: console.log(name + ".onColorChanged: " + color); |
|
69 | onColorChanged: console.log(name + ".onColorChanged: " + color); | |
70 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); |
|
70 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); | |
71 | onBorderWidthChanged: console.log(name + ".onBorderChanged: " + borderWidth); |
|
71 | onBorderWidthChanged: console.log(name + ".onBorderChanged: " + borderWidth); | |
72 | // onCountChanged: console.log(name + ".onCountChanged: " + count); |
|
72 | // onCountChanged: console.log(name + ".onCountChanged: " + count); | |
|
73 | onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state); | |||
73 |
|
|
74 | } | |
74 |
|
75 | |||
75 | AreaSeries { |
|
76 | AreaSeries { | |
76 | name: "area 2" |
|
77 | name: "area 2" | |
77 |
|
78 | |||
78 | upperSeries: LineSeries { |
|
79 | upperSeries: LineSeries { | |
79 | XYPoint { x: 0; y: 0.5 } |
|
80 | XYPoint { x: 0; y: 0.5 } | |
80 | XYPoint { x: 1; y: 1.5 } |
|
81 | XYPoint { x: 1; y: 1.5 } | |
81 | XYPoint { x: 2; y: 0.3 } |
|
82 | XYPoint { x: 2; y: 0.3 } | |
82 | XYPoint { x: 3; y: 1.5 } |
|
83 | XYPoint { x: 3; y: 1.5 } | |
83 | XYPoint { x: 4; y: 0.1 } |
|
84 | XYPoint { x: 4; y: 0.1 } | |
84 | XYPoint { x: 5; y: 0.3 } |
|
85 | XYPoint { x: 5; y: 0.3 } | |
85 | XYPoint { x: 6; y: 1.2 } |
|
86 | XYPoint { x: 6; y: 1.2 } | |
86 | XYPoint { x: 7; y: 1.3 } |
|
87 | XYPoint { x: 7; y: 1.3 } | |
87 | XYPoint { x: 8; y: 0.2 } |
|
88 | XYPoint { x: 8; y: 0.2 } | |
88 | XYPoint { x: 9; y: 0.1 } |
|
89 | XYPoint { x: 9; y: 0.1 } | |
89 | XYPoint { x: 10; y: 3.2 } |
|
90 | XYPoint { x: 10; y: 3.2 } | |
90 | XYPoint { x: 11; y: 4.6 } |
|
91 | XYPoint { x: 11; y: 4.6 } | |
91 | } |
|
92 | } | |
92 |
|
93 | |||
93 | onNameChanged: console.log(name + ".onNameChanged: " + name); |
|
94 | onNameChanged: console.log(name + ".onNameChanged: " + name); | |
94 | onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); |
|
95 | onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); | |
95 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
96 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
96 | onSelected: console.log(name + ".onSelected"); |
|
97 | onSelected: console.log(name + ".onSelected"); | |
97 | onColorChanged: console.log(name + ".onColorChanged: " + color); |
|
98 | onColorChanged: console.log(name + ".onColorChanged: " + color); | |
98 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); |
|
99 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); | |
99 | } |
|
100 | } | |
100 | } |
|
101 | } |
@@ -1,66 +1,67 | |||||
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 | import QtQuick 1.0 |
|
21 | import QtQuick 1.0 | |
22 | import QtCommercial.Chart 1.1 |
|
22 | import QtCommercial.Chart 1.1 | |
23 |
|
23 | |||
24 | ChartView { |
|
24 | ChartView { | |
25 | property variant series: lineSeries |
|
25 | property variant series: lineSeries | |
26 |
|
26 | |||
27 | title: "line series" |
|
27 | title: "line series" | |
28 | anchors.fill: parent |
|
28 | anchors.fill: parent | |
29 | animationOptions: ChartView.SeriesAnimations |
|
29 | animationOptions: ChartView.SeriesAnimations | |
30 |
|
30 | |||
31 | LineSeries { |
|
31 | LineSeries { | |
32 | id: lineSeries |
|
32 | id: lineSeries | |
33 | name: "line 1" |
|
33 | name: "line 1" | |
34 | XYPoint { x: 0; y: 0 } |
|
34 | XYPoint { x: 0; y: 0 } | |
35 | XYPoint { x: 1.1; y: 2.1 } |
|
35 | XYPoint { x: 1.1; y: 2.1 } | |
36 | XYPoint { x: 1.9; y: 3.3 } |
|
36 | XYPoint { x: 1.9; y: 3.3 } | |
37 | XYPoint { x: 2.1; y: 2.1 } |
|
37 | XYPoint { x: 2.1; y: 2.1 } | |
38 | XYPoint { x: 2.9; y: 4.9 } |
|
38 | XYPoint { x: 2.9; y: 4.9 } | |
39 | XYPoint { x: 3.4; y: 3.0 } |
|
39 | XYPoint { x: 3.4; y: 3.0 } | |
40 | XYPoint { x: 4.1; y: 3.3 } |
|
40 | XYPoint { x: 4.1; y: 3.3 } | |
41 |
|
41 | |||
42 | onNameChanged: console.log("lineSeries.onNameChanged: " + name); |
|
42 | onNameChanged: console.log("lineSeries.onNameChanged: " + name); | |
43 | onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible); |
|
43 | onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible); | |
44 | onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity); |
|
44 | onOpacityChanged: console.log(name + ".onOpacityChanged: " + opacity); | |
45 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
45 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
46 | onPointReplaced: console.log("lineSeries.onPointReplaced: " + index); |
|
46 | onPointReplaced: console.log("lineSeries.onPointReplaced: " + index); | |
47 | onPointRemoved: console.log("lineSeries.onPointRemoved: " + index); |
|
47 | onPointRemoved: console.log("lineSeries.onPointRemoved: " + index); | |
48 | onPointAdded: console.log("lineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y); |
|
48 | onPointAdded: console.log("lineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y); | |
49 | onColorChanged: console.log("lineSeries.onColorChanged: " + color); |
|
49 | onColorChanged: console.log("lineSeries.onColorChanged: " + color); | |
50 | onWidthChanged: console.log("lineSeries.onWidthChanged: " + width); |
|
50 | onWidthChanged: console.log("lineSeries.onWidthChanged: " + width); | |
51 | onStyleChanged: console.log("lineSeries.onStyleChanged: " + style); |
|
51 | onStyleChanged: console.log("lineSeries.onStyleChanged: " + style); | |
52 | onCapStyleChanged: console.log("lineSeries.onCapStyleChanged: " + capStyle); |
|
52 | onCapStyleChanged: console.log("lineSeries.onCapStyleChanged: " + capStyle); | |
53 | onCountChanged: console.log("lineSeries.onCountChanged: " + count); |
|
53 | onCountChanged: console.log("lineSeries.onCountChanged: " + count); | |
|
54 | onHovered: console.log("lineSeries.onHovered:" + point.x + "," + point.y + " " + state); | |||
54 | } |
|
55 | } | |
55 |
|
56 | |||
56 | LineSeries { |
|
57 | LineSeries { | |
57 | name: "line 2" |
|
58 | name: "line 2" | |
58 | XYPoint { x: 1.1; y: 1.1 } |
|
59 | XYPoint { x: 1.1; y: 1.1 } | |
59 | XYPoint { x: 1.9; y: 2.3 } |
|
60 | XYPoint { x: 1.9; y: 2.3 } | |
60 | XYPoint { x: 2.1; y: 1.1 } |
|
61 | XYPoint { x: 2.1; y: 1.1 } | |
61 | XYPoint { x: 2.9; y: 3.9 } |
|
62 | XYPoint { x: 2.9; y: 3.9 } | |
62 | XYPoint { x: 3.4; y: 2.0 } |
|
63 | XYPoint { x: 3.4; y: 2.0 } | |
63 | XYPoint { x: 4.1; y: 2.3 } |
|
64 | XYPoint { x: 4.1; y: 2.3 } | |
64 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
65 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
65 | } |
|
66 | } | |
66 | } |
|
67 | } |
General Comments 0
You need to be logged in to leave comments.
Login now