@@ -1,66 +1,70 | |||
|
1 | 1 | include($QT_INSTALL_DOCS/global/macros.qdocconf) |
|
2 | 2 | include($QT_INSTALL_DOCS/global/qt-cpp-defines.qdocconf) |
|
3 | 3 | include($QT_INSTALL_DOCS/global/compat.qdocconf) |
|
4 | 4 | include($QT_INSTALL_DOCS/global/fileextensions.qdocconf) |
|
5 | 5 | include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf) |
|
6 | 6 | |
|
7 | 7 | project = Qt Charts |
|
8 | 8 | description = Qt Charts Reference Documentation |
|
9 | 9 | version = 2.0.0 |
|
10 | 10 | |
|
11 | sourcedirs += .. | |
|
12 | headerdirs += .. | |
|
11 | sourcedirs += .. \ | |
|
12 | ../../chartsqml2 | |
|
13 | headerdirs += .. \ | |
|
14 | ../../chartsqml2 | |
|
13 | 15 | exampledirs += ../../../examples/charts \ |
|
14 | 16 | snippets |
|
15 | 17 | imagedirs += images |
|
16 | 18 | examplesinstallpath = charts |
|
17 | 19 | |
|
20 | sources.fileextensions = "*.cpp *.qdoc" | |
|
21 | ||
|
18 | 22 | indexes += $QT_INSTALL_DOCS/qtcore/qtcore.index \ |
|
19 | 23 | $QT_INSTALL_DOCS/qtgui/qtgui.index \ |
|
20 | 24 | $QT_INSTALL_DOCS/qtqml/qtqml.index \ |
|
21 | 25 | $QT_INSTALL_DOCS/qtquick/qtquick.index \ |
|
22 | 26 | $QT_INSTALL_DOCS/qtmultimedia/qtmultimedia.index |
|
23 | 27 | |
|
24 | 28 | Cpp.ignoretokens = Q_INVOKABLE \ |
|
25 | 29 | QT_CHARTS_EXPORT \ |
|
26 | 30 | QT_CHARTS_END_NAMESPACE \ |
|
27 | 31 | QT_CHARTS_BEGIN_NAMESPACE |
|
28 | 32 | |
|
29 | 33 | qhp.projects = QtCharts |
|
30 | 34 | qhp.QtCharts.file = qtcharts.qhp |
|
31 | 35 | qhp.QtCharts.namespace = com.digia.qtcharts.200 |
|
32 | 36 | qhp.QtCharts.virtualFolder = qtcharts |
|
33 | 37 | qhp.QtCharts.indexTitle = Qt Charts Reference |
|
34 | 38 | qhp.QtCharts.indexRoot = |
|
35 | 39 | |
|
36 | 40 | qhp.QtCharts.filterAttributes = qtcharts 2.0.0 qtrefdoc |
|
37 | 41 | qhp.QtCharts.customFilters.Qt.name = QtCharts 2.0.0 |
|
38 | 42 | qhp.QtCharts.customFilters.Qt.filterAttributes = qtcharts 2.0.0 |
|
39 | 43 | |
|
40 | 44 | qhp.QtCharts.subprojects = gettingstarted classes types examples |
|
41 | 45 | |
|
42 | 46 | qhp.QtCharts.subprojects.gettingstarted.title = Getting Started |
|
43 | 47 | qhp.QtCharts.subprojects.gettingstarted.indexTitle = Qt Charts Getting Started |
|
44 | 48 | qhp.QtCharts.subprojects.gettingstarted.selectors = fake:page |
|
45 | 49 | qhp.QtCharts.subprojects.gettingstarted.sortPages = true |
|
46 | 50 | |
|
47 | 51 | qhp.QtCharts.subprojects.classes.title = C++ Classes |
|
48 | 52 | qhp.QtCharts.subprojects.classes.indexTitle = Qt Charts C++ Classes |
|
49 | 53 | qhp.QtCharts.subprojects.classes.selectors = class |
|
50 | 54 | qhp.QtCharts.subprojects.classes.sortPages = true |
|
51 | 55 | |
|
52 | 56 | qhp.QtCharts.subprojects.types.title = QML Types |
|
53 | 57 | qhp.QtCharts.subprojects.types.indexTitle = Qt Charts QML Types |
|
54 | 58 | qhp.QtCharts.subprojects.types.selectors = qmlclass |
|
55 | 59 | qhp.QtCharts.subprojects.types.sortPages = true |
|
56 | 60 | |
|
57 | 61 | qhp.QtCharts.subprojects.examples.title = Examples |
|
58 | 62 | qhp.QtCharts.subprojects.examples.indexTitle = Qt Charts Examples |
|
59 | 63 | qhp.QtCharts.subprojects.examples.selectors = fake:example |
|
60 | 64 | qhp.QtCharts.subprojects.examples.sortPages = true |
|
61 | 65 | |
|
62 | 66 | navigation.landingpage = Qt Charts |
|
63 | 67 | navigation.cppclassespage = Qt Charts C++ Classes |
|
64 | 68 | navigation.qmltypespage = Qt Charts QML Types |
|
65 | 69 | |
|
66 | 70 | buildversion = Qt Charts $QT_VERSION Reference Documentation |
@@ -1,423 +1,427 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativebarseries.h" |
|
22 | 22 | #include "declarativeboxplotseries.h" |
|
23 | 23 | #include <QtCharts/QBoxSet> |
|
24 | 24 | #include <QtCharts/QVBoxPlotModelMapper> |
|
25 | 25 | |
|
26 | 26 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | /*! |
|
29 | 29 | \qmltype BoxSet |
|
30 | 30 | \instantiates QBoxSet |
|
31 | 31 | \inqmlmodule QtCharts |
|
32 | 32 | |
|
33 | \brief Building block for box-and-whiskers chart. | |
|
34 | ||
|
33 | 35 | BoxSet represents one box-and-whiskers item. It takes five values to create a graphical |
|
34 | 36 | representation of range and three medians. There are two ways to give the values. The first one |
|
35 | 37 | is with constructor or with append method. In these the values have to be given in the following |
|
36 | 38 | order: lower extreme, lower quartile, median, upper quartile and upper extreme. The second |
|
37 | 39 | method is to create an empty QBoxSet instance and give the values using value specific methods. |
|
38 | 40 | \sa BoxPlotSeries |
|
39 | 41 | */ |
|
40 | 42 | /*! |
|
41 | 43 | \qmlproperty string BoxSet::values |
|
42 | 44 | The values on the box-and-whiskers set. |
|
43 | 45 | */ |
|
44 | 46 | /*! |
|
45 | 47 | \qmlproperty string BoxSet::label |
|
46 | 48 | Defines the label of the box-and-whiskers set. |
|
47 | 49 | */ |
|
48 | 50 | /*! |
|
49 | 51 | \qmlproperty int BoxSet::count |
|
50 | 52 | The count of values on the box-and-whiskers set |
|
51 | 53 | */ |
|
52 | 54 | /*! |
|
53 | 55 | \qmlmethod void BoxSet::at(int index) |
|
54 | 56 | Returns the value at \a index position. |
|
55 | 57 | */ |
|
56 | 58 | /*! |
|
57 | 59 | \qmlmethod void BoxSet::append(qreal value) |
|
58 | 60 | Appends new value \a value to the end of set. |
|
59 | 61 | */ |
|
60 | 62 | /*! |
|
61 | 63 | \qmlmethod void BoxSet::clear() |
|
62 | 64 | Sets all values on the set to 0. |
|
63 | 65 | */ |
|
64 | 66 | /*! |
|
65 | 67 | \qmlmethod void BoxSet::setValue(int index, qreal value) |
|
66 | 68 | Sets a new \a value on the \a index position. |
|
67 | 69 | */ |
|
68 | 70 | /*! |
|
69 | 71 | \qmlsignal BoxSet::onClicked() |
|
70 | 72 | This signal is emitted when the user clicks with a mouse on top of box-and-whiskers item. |
|
71 | 73 | */ |
|
72 | 74 | /*! |
|
73 | 75 | \qmlsignal BoxSet::onHovered(bool status) |
|
74 | 76 | The signal is emitted if mouse is hovered on top of box-and-whiskers item. |
|
75 | 77 | Parameter \a status is true, if mouse entered on top of the item, and false if mouse left from top of the item. |
|
76 | 78 | */ |
|
77 | 79 | /*! |
|
78 | 80 | \qmlsignal BoxSet::onPenChanged() |
|
79 | 81 | This signal is emitted when the pen of the box-and-whiskers item has changed. |
|
80 | 82 | */ |
|
81 | 83 | /*! |
|
82 | 84 | \qmlsignal BoxSet::onBrushChanged() |
|
83 | 85 | This signal is emitted when the brush of the box-and-whiskers item has changed. |
|
84 | 86 | */ |
|
85 | 87 | /*! |
|
86 | 88 | \qmlsignal BoxSet::onChangedValues() |
|
87 | 89 | This signal is emitted when multiple values have been changed on the box-and-whiskers item. |
|
88 | 90 | */ |
|
89 | 91 | /*! |
|
90 | 92 | \qmlsignal BoxSet::onChangedValue(int index) |
|
91 | 93 | This signal is emitted values the value in the box-and-whiskers item has been modified. |
|
92 | 94 | Parameter \a index indicates the position of the modified value. |
|
93 | 95 | */ |
|
94 | 96 | /*! |
|
95 | 97 | \qmlsignal BoxSet::onCleared() |
|
96 | 98 | This signal is emitted when all the values on the set are cleared to 0. |
|
97 | 99 | */ |
|
98 | 100 | |
|
99 | 101 | /*! |
|
100 | 102 | \qmltype BoxPlotSeries |
|
101 | 103 | \instantiates QBoxPlotSeries |
|
102 | 104 | \inqmlmodule QtCharts |
|
103 | 105 | |
|
104 | 106 | \inherits AbstractSeries |
|
105 | 107 | |
|
108 | \brief Series for creating box-and-whiskers chart. | |
|
109 | ||
|
106 | 110 | BoxPlotSeries represents a series of data shown as box-and-whiskers bars. The purpose of this |
|
107 | 111 | class is to act as a container for single box-and-whiskers items. Each item is drawn to own |
|
108 | 112 | slot. If chart includes multiple instances of BoxPlotSeries then box-and-whiskers items with the |
|
109 | 113 | same index are drawn to same slot. |
|
110 | 114 | |
|
111 | 115 | The following QML shows how to create a simple box-and-whiskers chart: |
|
112 | 116 | \code |
|
113 | 117 | import QtQuick 2.0 |
|
114 | 118 | import QtCharts 2.0 |
|
115 | 119 | |
|
116 | 120 | ChartView { |
|
117 | 121 | title: "Box Plot series" |
|
118 | 122 | width: 400 |
|
119 | 123 | height: 300 |
|
120 | 124 | theme: ChartView.ChartThemeBrownSand |
|
121 | 125 | legend.alignment: Qt.AlignBottom |
|
122 | 126 | |
|
123 | 127 | BoxPlotSeries { |
|
124 | 128 | id: plotSeries |
|
125 | 129 | name: "Income" |
|
126 | 130 | BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] } |
|
127 | 131 | BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] } |
|
128 | 132 | BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] } |
|
129 | 133 | BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] } |
|
130 | 134 | BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] } |
|
131 | 135 | } |
|
132 | 136 | } |
|
133 | 137 | \endcode |
|
134 | 138 | |
|
135 | 139 | \beginfloatleft |
|
136 | 140 | \image examples_qmlboxplot.png |
|
137 | 141 | \endfloat |
|
138 | 142 | \clearfloat |
|
139 | 143 | */ |
|
140 | 144 | |
|
141 | 145 | /*! |
|
142 | 146 | \qmlmethod BoxPlotSeries::append(string label, VariantList values) |
|
143 | 147 | Appends a new box-and-whiskers set with \a label and \a values to the series. |
|
144 | 148 | */ |
|
145 | 149 | /*! |
|
146 | 150 | \qmlmethod BoxPlotSeries::append(BoxSet box) |
|
147 | 151 | Appends the \a box to the series. |
|
148 | 152 | */ |
|
149 | 153 | /*! |
|
150 | 154 | \qmlmethod BoxPlotSeries::insert(int index, string label, VariantList values) |
|
151 | 155 | Inserts a new box-and-whiskers set with \a label and \a values at the \a index position. |
|
152 | 156 | */ |
|
153 | 157 | /*! |
|
154 | 158 | \qmlmethod BoxPlotSeries::remove(QBoxSet boxset) |
|
155 | 159 | Removes the \a boxset from the series. |
|
156 | 160 | */ |
|
157 | 161 | /*! |
|
158 | 162 | \qmlmethod BoxPlotSeries::clear() |
|
159 | 163 | Removes all boxsets from the series. Deletes removed sets. |
|
160 | 164 | */ |
|
161 | 165 | /*! |
|
162 | 166 | \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset); |
|
163 | 167 | Signal is emitted when the user clicks the \a boxset on the chart. |
|
164 | 168 | */ |
|
165 | 169 | /*! |
|
166 | 170 | \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset); |
|
167 | 171 | Signal is emitted when there is change in hover \a status over \a boxset. |
|
168 | 172 | */ |
|
169 | 173 | /*! |
|
170 | 174 | \qmlsignal BoxPlotSeries::onCountChanged(); |
|
171 | 175 | Signal is emitted when there is change in count of box-and-whiskers items in the series. |
|
172 | 176 | */ |
|
173 | 177 | /*! |
|
174 | 178 | \qmlsignal BoxPlotSeries::onBoxsetsAdded() |
|
175 | 179 | Signal is emitted when new box-and-whiskers sets are added to the series. |
|
176 | 180 | */ |
|
177 | 181 | /*! |
|
178 | 182 | \qmlsignal BoxPlotSeries::onBoxsetsRemoved() |
|
179 | 183 | Signal is emitted when new box-and-whiskers sets are removed from the series. |
|
180 | 184 | */ |
|
181 | 185 | /*! |
|
182 | 186 | \qmlproperty AbstractAxis BoxPlotSeries::axisX |
|
183 | 187 | The x axis used for the series. If you leave both axisX and axisXTop undefined, a BarCategoriesAxis is created for |
|
184 | 188 | the series. |
|
185 | 189 | \sa axisXTop |
|
186 | 190 | */ |
|
187 | 191 | /*! |
|
188 | 192 | \qmlproperty AbstractAxis BoxPlotSeries::axisY |
|
189 | 193 | The y axis used for the series. If you leave both axisY and axisYRight undefined, a ValueAxis is created for |
|
190 | 194 | the series. |
|
191 | 195 | \sa axisYRight |
|
192 | 196 | */ |
|
193 | 197 | /*! |
|
194 | 198 | \qmlproperty AbstractAxis BoxPlotSeries::axisXTop |
|
195 | 199 | The x axis used for the series, drawn on top of the chart view. Note that you can only provide either axisX or |
|
196 | 200 | axisXTop, but not both. |
|
197 | 201 | \sa axisX |
|
198 | 202 | */ |
|
199 | 203 | /*! |
|
200 | 204 | \qmlproperty AbstractAxis BoxPlotSeries::axisYRight |
|
201 | 205 | The y axis used for the series, drawn to the right on the chart view. Note that you can only provide either axisY |
|
202 | 206 | or axisYRight, but not both. |
|
203 | 207 | \sa axisY |
|
204 | 208 | */ |
|
205 | 209 | /*! |
|
206 | 210 | \qmlproperty bool BoxPlotSeries::boxOutlineVisible |
|
207 | 211 | This property configures the visibility of the middle box outline. |
|
208 | 212 | */ |
|
209 | 213 | /*! |
|
210 | 214 | \qmlproperty qreal BoxPlotSeries::boxWidth |
|
211 | 215 | This property configures the width of the box-and-whiskers item. The value signifies the relative |
|
212 | 216 | width of the box-and-whiskers item inside its own slot. The value can between 0.0 and 1.0. Negative values |
|
213 | 217 | are clamped to 0.0 and values over 1.0 are clamped to 1.0. |
|
214 | 218 | */ |
|
215 | 219 | /*! |
|
216 | 220 | \qmlproperty Pen BoxPlotSeries::pen |
|
217 | 221 | This property configures the pen of the box-and-whiskers items. |
|
218 | 222 | */ |
|
219 | 223 | /*! |
|
220 | 224 | \qmlproperty Brush BoxPlotSeries::brush |
|
221 | 225 | This property configures the brush of the box-and-whiskers items. |
|
222 | 226 | */ |
|
223 | 227 | /*! |
|
224 | 228 | \qmlproperty int BoxPlotSeries::count |
|
225 | 229 | The count of sets in series. |
|
226 | 230 | */ |
|
227 | 231 | /*! |
|
228 | 232 | \qmlsignal BoxPlotSeries::onBoxOutlineVisibilityChanged() |
|
229 | 233 | Signal is emitted when the middle box outline visibility is changed. |
|
230 | 234 | */ |
|
231 | 235 | /*! |
|
232 | 236 | \qmlsignal BoxPlotSeries::onBoxWidthChanged() |
|
233 | 237 | Signal is emitted when the width of the box-and-whiskers item is changed. |
|
234 | 238 | */ |
|
235 | 239 | /*! |
|
236 | 240 | \qmlsignal BoxPlotSeries::onPenChanged() |
|
237 | 241 | Signal is emitted when the pen for box-and-whiskers items has changed. |
|
238 | 242 | */ |
|
239 | 243 | /*! |
|
240 | 244 | \qmlsignal BoxPlotSeries::onBrushChanged() |
|
241 | 245 | Signal is emitted when the brush for box-and-whiskers items has changed. |
|
242 | 246 | */ |
|
243 | 247 | /*! |
|
244 | 248 | \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset) |
|
245 | 249 | Signal is emitted when the user clicks the \a boxset on the chart. |
|
246 | 250 | */ |
|
247 | 251 | /*! |
|
248 | 252 | \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset) |
|
249 | 253 | Signal is emitted when there is change in hover \a status over \a boxset. |
|
250 | 254 | */ |
|
251 | 255 | /*! |
|
252 | 256 | \qmlsignal BoxPlotSeries::onAxisXChanged(AbstractAxis axis) |
|
253 | 257 | Signal is emitted when there is change in X axis. |
|
254 | 258 | */ |
|
255 | 259 | /*! |
|
256 | 260 | \qmlsignal BoxPlotSeries::onAxisYChanged(AbstractAxis axis) |
|
257 | 261 | Signal is emitted when there is change in Y axis. |
|
258 | 262 | */ |
|
259 | 263 | /*! |
|
260 | 264 | \qmlsignal BoxPlotSeries::onAxisXTopChanged(AbstractAxis axis) |
|
261 | 265 | Signal is emitted when there is change in top X axis. |
|
262 | 266 | */ |
|
263 | 267 | /*! |
|
264 | 268 | \qmlsignal BoxPlotSeries::onAxisYRightChanged(AbstractAxis axis) |
|
265 | 269 | Signal is emitted when there is change in Y right axis. |
|
266 | 270 | */ |
|
267 | 271 | |
|
268 | 272 | |
|
269 | 273 | DeclarativeBoxSet::DeclarativeBoxSet(const QString label, QObject *parent) |
|
270 | 274 | : QBoxSet(label, parent) |
|
271 | 275 | { |
|
272 | 276 | connect(this, SIGNAL(valuesChanged()), this, SIGNAL(changedValues())); |
|
273 | 277 | connect(this, SIGNAL(valueChanged(int)), this, SIGNAL(changedValue(int))); |
|
274 | 278 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); |
|
275 | 279 | } |
|
276 | 280 | |
|
277 | 281 | QVariantList DeclarativeBoxSet::values() |
|
278 | 282 | { |
|
279 | 283 | QVariantList values; |
|
280 | 284 | for (int i(0); i < 5; i++) |
|
281 | 285 | values.append(QVariant(QBoxSet::at(i))); |
|
282 | 286 | return values; |
|
283 | 287 | } |
|
284 | 288 | |
|
285 | 289 | void DeclarativeBoxSet::setValues(QVariantList values) |
|
286 | 290 | { |
|
287 | 291 | for (int i(0); i < values.count(); i++) { |
|
288 | 292 | if (values.at(i).canConvert(QVariant::Double)) |
|
289 | 293 | QBoxSet::append(values[i].toDouble()); |
|
290 | 294 | } |
|
291 | 295 | } |
|
292 | 296 | |
|
293 | 297 | QString DeclarativeBoxSet::brushFilename() const |
|
294 | 298 | { |
|
295 | 299 | return m_brushFilename; |
|
296 | 300 | } |
|
297 | 301 | |
|
298 | 302 | void DeclarativeBoxSet::setBrushFilename(const QString &brushFilename) |
|
299 | 303 | { |
|
300 | 304 | QImage brushImage(brushFilename); |
|
301 | 305 | if (QBoxSet::brush().textureImage() != brushImage) { |
|
302 | 306 | QBrush brush = QBoxSet::brush(); |
|
303 | 307 | brush.setTextureImage(brushImage); |
|
304 | 308 | QBoxSet::setBrush(brush); |
|
305 | 309 | m_brushFilename = brushFilename; |
|
306 | 310 | m_brushImage = brushImage; |
|
307 | 311 | emit brushFilenameChanged(brushFilename); |
|
308 | 312 | } |
|
309 | 313 | } |
|
310 | 314 | |
|
311 | 315 | void DeclarativeBoxSet::handleBrushChanged() |
|
312 | 316 | { |
|
313 | 317 | // If the texture image of the brush has changed along the brush |
|
314 | 318 | // the brush file name needs to be cleared. |
|
315 | 319 | if (!m_brushFilename.isEmpty() && QBoxSet::brush().textureImage() != m_brushImage) { |
|
316 | 320 | m_brushFilename.clear(); |
|
317 | 321 | emit brushFilenameChanged(QString("")); |
|
318 | 322 | } |
|
319 | 323 | } |
|
320 | 324 | |
|
321 | 325 | // ===================================================== |
|
322 | 326 | |
|
323 | 327 | DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QQuickItem *parent) : |
|
324 | 328 | QBoxPlotSeries(parent), |
|
325 | 329 | m_axes(new DeclarativeAxes(this)) |
|
326 | 330 | { |
|
327 | 331 | connect(m_axes, SIGNAL(axisXChanged(QAbstractAxis*)), this, SIGNAL(axisXChanged(QAbstractAxis*))); |
|
328 | 332 | connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*))); |
|
329 | 333 | connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*))); |
|
330 | 334 | connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*))); |
|
331 | 335 | connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*))); |
|
332 | 336 | connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*))); |
|
333 | 337 | connect(this, SIGNAL(brushChanged()), this, SLOT(handleBrushChanged())); |
|
334 | 338 | } |
|
335 | 339 | |
|
336 | 340 | void DeclarativeBoxPlotSeries::classBegin() |
|
337 | 341 | { |
|
338 | 342 | } |
|
339 | 343 | |
|
340 | 344 | void DeclarativeBoxPlotSeries::componentComplete() |
|
341 | 345 | { |
|
342 | 346 | foreach (QObject *child, children()) { |
|
343 | 347 | if (qobject_cast<DeclarativeBoxSet *>(child)) { |
|
344 | 348 | QBoxPlotSeries::append(qobject_cast<DeclarativeBoxSet *>(child)); |
|
345 | 349 | } else if (qobject_cast<QVBoxPlotModelMapper *>(child)) { |
|
346 | 350 | QVBoxPlotModelMapper *mapper = qobject_cast<QVBoxPlotModelMapper *>(child); |
|
347 | 351 | mapper->setSeries(this); |
|
348 | 352 | } |
|
349 | 353 | } |
|
350 | 354 | } |
|
351 | 355 | |
|
352 | 356 | QQmlListProperty<QObject> DeclarativeBoxPlotSeries::seriesChildren() |
|
353 | 357 | { |
|
354 | 358 | return QQmlListProperty<QObject>(this, 0, &DeclarativeBoxPlotSeries::appendSeriesChildren ,0,0,0); |
|
355 | 359 | } |
|
356 | 360 | |
|
357 | 361 | void DeclarativeBoxPlotSeries::appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element) |
|
358 | 362 | { |
|
359 | 363 | // Empty implementation; the children are parsed in componentComplete instead |
|
360 | 364 | Q_UNUSED(list); |
|
361 | 365 | Q_UNUSED(element); |
|
362 | 366 | } |
|
363 | 367 | |
|
364 | 368 | DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index) |
|
365 | 369 | { |
|
366 | 370 | QList<QBoxSet *> setList = boxSets(); |
|
367 | 371 | if (index >= 0 && index < setList.count()) |
|
368 | 372 | return qobject_cast<DeclarativeBoxSet *>(setList[index]); |
|
369 | 373 | |
|
370 | 374 | return 0; |
|
371 | 375 | } |
|
372 | 376 | |
|
373 | 377 | DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString label, QVariantList values) |
|
374 | 378 | { |
|
375 | 379 | DeclarativeBoxSet *barset = new DeclarativeBoxSet(label, this); |
|
376 | 380 | barset->setValues(values); |
|
377 | 381 | if (QBoxPlotSeries::insert(index, barset)) |
|
378 | 382 | return barset; |
|
379 | 383 | delete barset; |
|
380 | 384 | return 0; |
|
381 | 385 | } |
|
382 | 386 | |
|
383 | 387 | void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset) |
|
384 | 388 | { |
|
385 | 389 | emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset)); |
|
386 | 390 | } |
|
387 | 391 | |
|
388 | 392 | void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset) |
|
389 | 393 | { |
|
390 | 394 | emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset)); |
|
391 | 395 | } |
|
392 | 396 | |
|
393 | 397 | QString DeclarativeBoxPlotSeries::brushFilename() const |
|
394 | 398 | { |
|
395 | 399 | return m_brushFilename; |
|
396 | 400 | } |
|
397 | 401 | |
|
398 | 402 | void DeclarativeBoxPlotSeries::setBrushFilename(const QString &brushFilename) |
|
399 | 403 | { |
|
400 | 404 | QImage brushImage(brushFilename); |
|
401 | 405 | if (QBoxPlotSeries::brush().textureImage() != brushImage) { |
|
402 | 406 | QBrush brush = QBoxPlotSeries::brush(); |
|
403 | 407 | brush.setTextureImage(brushImage); |
|
404 | 408 | QBoxPlotSeries::setBrush(brush); |
|
405 | 409 | m_brushFilename = brushFilename; |
|
406 | 410 | m_brushImage = brushImage; |
|
407 | 411 | emit brushFilenameChanged(brushFilename); |
|
408 | 412 | } |
|
409 | 413 | } |
|
410 | 414 | |
|
411 | 415 | void DeclarativeBoxPlotSeries::handleBrushChanged() |
|
412 | 416 | { |
|
413 | 417 | // If the texture image of the brush has changed along the brush |
|
414 | 418 | // the brush file name needs to be cleared. |
|
415 | 419 | if (!m_brushFilename.isEmpty() && QBoxPlotSeries::brush().textureImage() != m_brushImage) { |
|
416 | 420 | m_brushFilename.clear(); |
|
417 | 421 | emit brushFilenameChanged(QString("")); |
|
418 | 422 | } |
|
419 | 423 | } |
|
420 | 424 | |
|
421 | 425 | #include "moc_declarativeboxplotseries.cpp" |
|
422 | 426 | |
|
423 | 427 | QT_CHARTS_END_NAMESPACE |
@@ -1,1055 +1,1057 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativechart.h" |
|
22 | 22 | #include <QtGui/QPainter> |
|
23 | 23 | #include "declarativelineseries.h" |
|
24 | 24 | #include "declarativeareaseries.h" |
|
25 | 25 | #include "declarativebarseries.h" |
|
26 | 26 | #include "declarativepieseries.h" |
|
27 | 27 | #include "declarativesplineseries.h" |
|
28 | 28 | #include "declarativeboxplotseries.h" |
|
29 | 29 | #include "declarativescatterseries.h" |
|
30 | 30 | #include <QtCharts/QBarCategoryAxis> |
|
31 | 31 | #include <QtCharts/QValueAxis> |
|
32 | 32 | #include <QtCharts/QLogValueAxis> |
|
33 | 33 | #include <QtCharts/QCategoryAxis> |
|
34 | 34 | #include <private/qabstractseries_p.h> |
|
35 | 35 | #include "declarativemargins.h" |
|
36 | 36 | #include <private/chartdataset_p.h> |
|
37 | 37 | #include "declarativeaxes.h" |
|
38 | 38 | #include <private/qchart_p.h> |
|
39 | 39 | #include <QtCharts/QPolarChart> |
|
40 | 40 | |
|
41 | 41 | #ifndef QT_ON_ARM |
|
42 | 42 | #include <QtCharts/QDateTimeAxis> |
|
43 | 43 | #endif |
|
44 | 44 | |
|
45 | 45 | #include <QtWidgets/QGraphicsSceneMouseEvent> |
|
46 | 46 | #include <QtWidgets/QGraphicsSceneHoverEvent> |
|
47 | 47 | #include <QtWidgets/QApplication> |
|
48 | 48 | #include <QtCore/QTimer> |
|
49 | 49 | #include <QtCore/QThread> |
|
50 | 50 | |
|
51 | 51 | QT_CHARTS_BEGIN_NAMESPACE |
|
52 | 52 | |
|
53 | 53 | /*! |
|
54 | 54 | \qmltype ChartView |
|
55 | 55 | \instantiates DeclarativeChart |
|
56 | 56 | \inqmlmodule QtCharts |
|
57 | 57 | |
|
58 | \brief Chart element. | |
|
59 | ||
|
58 | 60 | ChartView element is the parent that is responsible for showing different chart series types. |
|
59 | 61 | |
|
60 | 62 | The following QML shows how to create a simple chart with one pie series: |
|
61 | 63 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
62 | 64 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
63 | 65 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
64 | 66 | |
|
65 | 67 | \beginfloatleft |
|
66 | 68 | \image examples_qmlpiechart.png |
|
67 | 69 | \endfloat |
|
68 | 70 | \clearfloat |
|
69 | 71 | */ |
|
70 | 72 | |
|
71 | 73 | /*! |
|
72 | 74 | \qmlproperty Theme ChartView::theme |
|
73 | 75 | Theme defines the visual appearance of the chart, including for example colors, fonts, line |
|
74 | 76 | widths and chart background. |
|
75 | 77 | */ |
|
76 | 78 | |
|
77 | 79 | /*! |
|
78 | 80 | \qmlproperty Animation ChartView::animationOptions |
|
79 | 81 | Animation configuration of the chart. One of ChartView.NoAnimation, ChartView.GridAxisAnimations, |
|
80 | 82 | ChartView.SeriesAnimations or ChartView.AllAnimations. |
|
81 | 83 | */ |
|
82 | 84 | |
|
83 | 85 | /*! |
|
84 | 86 | \qmlproperty Font ChartView::titleFont |
|
85 | 87 | The title font of the chart. |
|
86 | 88 | |
|
87 | 89 | See the Qt documentation for more details of Font. |
|
88 | 90 | */ |
|
89 | 91 | |
|
90 | 92 | /*! |
|
91 | 93 | \qmlproperty string ChartView::title |
|
92 | 94 | The title of the chart, shown on top of the chart. |
|
93 | 95 | \sa ChartView::titleColor |
|
94 | 96 | */ |
|
95 | 97 | |
|
96 | 98 | /*! |
|
97 | 99 | \qmlproperty color ChartView::titleColor |
|
98 | 100 | The color of the title text. |
|
99 | 101 | */ |
|
100 | 102 | |
|
101 | 103 | /*! |
|
102 | 104 | \qmlproperty Legend ChartView::legend |
|
103 | 105 | The legend of the chart. Legend lists all the series, pie slices and bar sets added on the chart. |
|
104 | 106 | */ |
|
105 | 107 | |
|
106 | 108 | /*! |
|
107 | 109 | \qmlproperty int ChartView::count |
|
108 | 110 | The count of series added to the chart. |
|
109 | 111 | */ |
|
110 | 112 | |
|
111 | 113 | /*! |
|
112 | 114 | \qmlproperty color ChartView::backgroundColor |
|
113 | 115 | The color of the chart's background. By default background color is defined by chart theme. |
|
114 | 116 | \sa ChartView::theme |
|
115 | 117 | */ |
|
116 | 118 | |
|
117 | 119 | /*! |
|
118 | 120 | \qmlproperty real ChartView::backgroundRoundness |
|
119 | 121 | The diameter of the rounding cirle at the corners of the chart background. |
|
120 | 122 | */ |
|
121 | 123 | |
|
122 | 124 | /*! |
|
123 | 125 | \qmlproperty color ChartView::plotAreaColor |
|
124 | 126 | The color of the background of the chart's plot area. By default plot area background uses chart's |
|
125 | 127 | background color. |
|
126 | 128 | \sa ChartView::backgroundColor |
|
127 | 129 | */ |
|
128 | 130 | |
|
129 | 131 | /*! |
|
130 | 132 | \qmlproperty bool ChartView::dropShadowEnabled |
|
131 | 133 | The chart's border drop shadow. Set to true to enable drop shadow. |
|
132 | 134 | */ |
|
133 | 135 | |
|
134 | 136 | /*! |
|
135 | 137 | \qmlproperty real ChartView::topMargin |
|
136 | 138 | Deprecated; use margins instead. |
|
137 | 139 | */ |
|
138 | 140 | |
|
139 | 141 | /*! |
|
140 | 142 | \qmlproperty real ChartView::bottomMargin |
|
141 | 143 | Deprecated; use margins instead. |
|
142 | 144 | */ |
|
143 | 145 | |
|
144 | 146 | /*! |
|
145 | 147 | \qmlproperty real ChartView::leftMargin |
|
146 | 148 | Deprecated; use margins instead. |
|
147 | 149 | */ |
|
148 | 150 | |
|
149 | 151 | /*! |
|
150 | 152 | \qmlproperty real ChartView::rightMargin |
|
151 | 153 | Deprecated; use margins instead. |
|
152 | 154 | */ |
|
153 | 155 | |
|
154 | 156 | /*! |
|
155 | 157 | \qmlproperty Margins ChartView::minimumMargins |
|
156 | 158 | Deprecated; use margins instead. |
|
157 | 159 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
158 | 160 | area of ChartView is used for drawing title, axes and legend. Please note that setting the |
|
159 | 161 | properties of minimumMargins may be bigger than the defined value, depending on other ChartView |
|
160 | 162 | properties that affect it's layout. If you need to know the actual plotting area used at any |
|
161 | 163 | given time, you can check ChartView::plotArea instead. |
|
162 | 164 | */ |
|
163 | 165 | |
|
164 | 166 | /*! |
|
165 | 167 | \qmlproperty rect ChartView::plotArea |
|
166 | 168 | The area on the ChartView that is used for drawing series. This is the ChartView rect without the |
|
167 | 169 | margins. |
|
168 | 170 | \sa ChartView::minimumMargins |
|
169 | 171 | */ |
|
170 | 172 | |
|
171 | 173 | /*! |
|
172 | 174 | \qmlproperty Margins ChartView::margins |
|
173 | 175 | The minimum margins allowed between the outer bounds and the plotArea of the ChartView. Margins |
|
174 | 176 | area of ChartView is used for drawing title, axes and legend. |
|
175 | 177 | */ |
|
176 | 178 | |
|
177 | 179 | /*! |
|
178 | 180 | \qmlproperty bool ChartView::localizeNumbers |
|
179 | 181 | \since QtCharts 2.0 |
|
180 | 182 | When \c{true}, all generated numbers appearing in various series and axis labels will be |
|
181 | 183 | localized using the default QLocale of the application, which defaults to the system locale. |
|
182 | 184 | When \c{false}, the "C" locale is always used. |
|
183 | 185 | Defaults to \c{false}. |
|
184 | 186 | |
|
185 | 187 | \sa locale |
|
186 | 188 | */ |
|
187 | 189 | |
|
188 | 190 | /*! |
|
189 | 191 | \qmlproperty locale ChartView::locale |
|
190 | 192 | \since QtCharts 2.0 |
|
191 | 193 | Sets the locale used to format various chart labels when localizeNumbers is \c{true}. |
|
192 | 194 | This also determines the locale used to format DateTimeAxis labels regardless of |
|
193 | 195 | localizeNumbers property. |
|
194 | 196 | Defaults to application default locale at the time the chart is constructed. |
|
195 | 197 | |
|
196 | 198 | \sa localizeNumbers |
|
197 | 199 | */ |
|
198 | 200 | |
|
199 | 201 | /*! |
|
200 | 202 | \qmlmethod AbstractSeries ChartView::series(int index) |
|
201 | 203 | Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with |
|
202 | 204 | the count property of the chart. |
|
203 | 205 | */ |
|
204 | 206 | |
|
205 | 207 | /*! |
|
206 | 208 | \qmlmethod AbstractSeries ChartView::series(string name) |
|
207 | 209 | Returns the first series on the chart with \a name. If there is no series with that name, returns null. |
|
208 | 210 | */ |
|
209 | 211 | |
|
210 | 212 | /*! |
|
211 | 213 | \qmlmethod AbstractSeries ChartView::createSeries(SeriesType type, string name, AbstractAxis axisX, AbstractAxis axisY) |
|
212 | 214 | Creates a series object of \a type to the chart with name \a name, optional axis \a axisX and |
|
213 | 215 | optional axis \a axisY. For example: |
|
214 | 216 | \code |
|
215 | 217 | // lineSeries is a LineSeries object that has already been added to the ChartView; re-use it's axes |
|
216 | 218 | var myAxisX = chartView.axisX(lineSeries); |
|
217 | 219 | var myAxisY = chartView.axisY(lineSeries); |
|
218 | 220 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter series", myAxisX, myAxisY); |
|
219 | 221 | \endcode |
|
220 | 222 | */ |
|
221 | 223 | |
|
222 | 224 | /*! |
|
223 | 225 | \qmlmethod ChartView::removeSeries(AbstractSeries series) |
|
224 | 226 | Removes the \a series from the chart. The series object is also destroyed. |
|
225 | 227 | */ |
|
226 | 228 | |
|
227 | 229 | /*! |
|
228 | 230 | \qmlmethod ChartView::removeAllSeries() |
|
229 | 231 | Removes all series from the chart. All the series objects are also destroyed. |
|
230 | 232 | */ |
|
231 | 233 | |
|
232 | 234 | /*! |
|
233 | 235 | \qmlmethod Axis ChartView::axisX(AbstractSeries series) |
|
234 | 236 | The x-axis of the series. |
|
235 | 237 | */ |
|
236 | 238 | |
|
237 | 239 | /*! |
|
238 | 240 | \qmlmethod Axis ChartView::axisY(AbstractSeries series) |
|
239 | 241 | The y-axis of the series. |
|
240 | 242 | */ |
|
241 | 243 | |
|
242 | 244 | /*! |
|
243 | 245 | \qmlmethod ChartView::zoomY(real factor) |
|
244 | 246 | Zooms in by \a factor on the center of the chart. |
|
245 | 247 | */ |
|
246 | 248 | |
|
247 | 249 | /*! |
|
248 | 250 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
249 | 251 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
250 | 252 | */ |
|
251 | 253 | |
|
252 | 254 | /*! |
|
253 | 255 | \qmlmethod ChartView::scrollRight(real pixels) |
|
254 | 256 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
255 | 257 | */ |
|
256 | 258 | |
|
257 | 259 | /*! |
|
258 | 260 | \qmlmethod ChartView::scrollUp(real pixels) |
|
259 | 261 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
260 | 262 | */ |
|
261 | 263 | |
|
262 | 264 | /*! |
|
263 | 265 | \qmlmethod ChartView::scrollDown(real pixels) |
|
264 | 266 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
265 | 267 | */ |
|
266 | 268 | |
|
267 | 269 | /*! |
|
268 | 270 | \qmlsignal ChartView::seriesAdded(AbstractSeries series) |
|
269 | 271 | The \a series has been added to the chart. |
|
270 | 272 | */ |
|
271 | 273 | |
|
272 | 274 | /*! |
|
273 | 275 | \qmlsignal ChartView::seriesRemoved(AbstractSeries series) |
|
274 | 276 | The \a series has been removed from the chart. Please note that \a series is no longer a valid |
|
275 | 277 | object after the signal handler has completed. |
|
276 | 278 | */ |
|
277 | 279 | |
|
278 | 280 | DeclarativeChart::DeclarativeChart(QQuickItem *parent) |
|
279 | 281 | : QQuickPaintedItem(parent) |
|
280 | 282 | { |
|
281 | 283 | initChart(QChart::ChartTypeCartesian); |
|
282 | 284 | } |
|
283 | 285 | |
|
284 | 286 | DeclarativeChart::DeclarativeChart(QChart::ChartType type, QQuickItem *parent) |
|
285 | 287 | : QQuickPaintedItem(parent) |
|
286 | 288 | { |
|
287 | 289 | initChart(type); |
|
288 | 290 | } |
|
289 | 291 | |
|
290 | 292 | void DeclarativeChart::initChart(QChart::ChartType type) |
|
291 | 293 | { |
|
292 | 294 | m_currentSceneImage = 0; |
|
293 | 295 | m_guiThreadId = QThread::currentThreadId(); |
|
294 | 296 | m_paintThreadId = 0; |
|
295 | 297 | m_updatePending = false; |
|
296 | 298 | |
|
297 | 299 | if (type == QChart::ChartTypePolar) |
|
298 | 300 | m_chart = new QPolarChart(); |
|
299 | 301 | else |
|
300 | 302 | m_chart = new QChart(); |
|
301 | 303 | |
|
302 | 304 | m_scene = new QGraphicsScene(this); |
|
303 | 305 | m_scene->addItem(m_chart); |
|
304 | 306 | |
|
305 | 307 | setAntialiasing(QQuickItem::antialiasing()); |
|
306 | 308 | connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(sceneChanged(QList<QRectF>))); |
|
307 | 309 | connect(this, SIGNAL(antialiasingChanged(bool)), this, SLOT(handleAntialiasingChanged(bool))); |
|
308 | 310 | |
|
309 | 311 | setAcceptedMouseButtons(Qt::AllButtons); |
|
310 | 312 | setAcceptHoverEvents(true); |
|
311 | 313 | |
|
312 | 314 | m_margins = new DeclarativeMargins(this); |
|
313 | 315 | m_margins->setTop(m_chart->margins().top()); |
|
314 | 316 | m_margins->setLeft(m_chart->margins().left()); |
|
315 | 317 | m_margins->setRight(m_chart->margins().right()); |
|
316 | 318 | m_margins->setBottom(m_chart->margins().bottom()); |
|
317 | 319 | connect(m_margins, SIGNAL(topChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
318 | 320 | connect(m_margins, SIGNAL(bottomChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
319 | 321 | connect(m_margins, SIGNAL(leftChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
320 | 322 | connect(m_margins, SIGNAL(rightChanged(int,int,int,int)), this, SLOT(changeMinimumMargins(int,int,int,int))); |
|
321 | 323 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), this, SLOT(handleSeriesAdded(QAbstractSeries*))); |
|
322 | 324 | connect(m_chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), this, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
323 | 325 | connect(m_chart, &QChart::plotAreaChanged, this, &DeclarativeChart::plotAreaChanged); |
|
324 | 326 | } |
|
325 | 327 | |
|
326 | 328 | void DeclarativeChart::handleSeriesAdded(QAbstractSeries *series) |
|
327 | 329 | { |
|
328 | 330 | emit seriesAdded(series); |
|
329 | 331 | } |
|
330 | 332 | |
|
331 | 333 | void DeclarativeChart::changeMinimumMargins(int top, int bottom, int left, int right) |
|
332 | 334 | { |
|
333 | 335 | m_chart->setMargins(QMargins(left, top, right, bottom)); |
|
334 | 336 | emit minimumMarginsChanged(); |
|
335 | 337 | } |
|
336 | 338 | |
|
337 | 339 | DeclarativeChart::~DeclarativeChart() |
|
338 | 340 | { |
|
339 | 341 | delete m_chart; |
|
340 | 342 | m_sceneImageLock.lock(); |
|
341 | 343 | delete m_currentSceneImage; |
|
342 | 344 | m_currentSceneImage = 0; |
|
343 | 345 | m_sceneImageLock.unlock(); |
|
344 | 346 | } |
|
345 | 347 | |
|
346 | 348 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
347 | 349 | { |
|
348 | 350 | if (event->type() == QEvent::ChildAdded) { |
|
349 | 351 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
350 | 352 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
351 | 353 | } |
|
352 | 354 | } |
|
353 | 355 | } |
|
354 | 356 | |
|
355 | 357 | void DeclarativeChart::componentComplete() |
|
356 | 358 | { |
|
357 | 359 | foreach (QObject *child, children()) { |
|
358 | 360 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
359 | 361 | // Add series to the chart |
|
360 | 362 | QAbstractSeries *series = qobject_cast<QAbstractSeries *>(child); |
|
361 | 363 | m_chart->addSeries(series); |
|
362 | 364 | |
|
363 | 365 | // Connect to axis changed signals (unless this is a pie series) |
|
364 | 366 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
365 | 367 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
366 | 368 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXTopSet(QAbstractAxis*))); |
|
367 | 369 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
368 | 370 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
369 | 371 | } |
|
370 | 372 | |
|
371 | 373 | initializeAxes(series); |
|
372 | 374 | } |
|
373 | 375 | } |
|
374 | 376 | |
|
375 | 377 | QQuickItem::componentComplete(); |
|
376 | 378 | } |
|
377 | 379 | |
|
378 | 380 | void DeclarativeChart::seriesAxisAttachHelper(QAbstractSeries *series, QAbstractAxis *axis, |
|
379 | 381 | Qt::Orientations orientation, |
|
380 | 382 | Qt::Alignment alignment) |
|
381 | 383 | { |
|
382 | 384 | if (!series->attachedAxes().contains(axis)) { |
|
383 | 385 | // Remove & delete old axes that are not attached to any other series |
|
384 | 386 | foreach (QAbstractAxis* oldAxis, m_chart->axes(orientation, series)) { |
|
385 | 387 | bool otherAttachments = false; |
|
386 | 388 | if (oldAxis != axis) { |
|
387 | 389 | foreach (QAbstractSeries *oldSeries, m_chart->series()) { |
|
388 | 390 | if (oldSeries != series && oldSeries->attachedAxes().contains(oldAxis)) { |
|
389 | 391 | otherAttachments = true; |
|
390 | 392 | break; |
|
391 | 393 | } |
|
392 | 394 | } |
|
393 | 395 | if (!otherAttachments) { |
|
394 | 396 | m_chart->removeAxis(oldAxis); |
|
395 | 397 | delete oldAxis; |
|
396 | 398 | } |
|
397 | 399 | } |
|
398 | 400 | } |
|
399 | 401 | if (!m_chart->axes(orientation).contains(axis)) |
|
400 | 402 | m_chart->addAxis(axis, alignment); |
|
401 | 403 | |
|
402 | 404 | series->attachAxis(axis); |
|
403 | 405 | } |
|
404 | 406 | } |
|
405 | 407 | |
|
406 | 408 | void DeclarativeChart::handleAxisXSet(QAbstractAxis *axis) |
|
407 | 409 | { |
|
408 | 410 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
409 | 411 | if (axis && s) { |
|
410 | 412 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignBottom); |
|
411 | 413 | } else { |
|
412 | 414 | qWarning() << "Trying to set axisX to null."; |
|
413 | 415 | } |
|
414 | 416 | } |
|
415 | 417 | |
|
416 | 418 | void DeclarativeChart::handleAxisXTopSet(QAbstractAxis *axis) |
|
417 | 419 | { |
|
418 | 420 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
419 | 421 | if (axis && s) { |
|
420 | 422 | seriesAxisAttachHelper(s, axis, Qt::Horizontal, Qt::AlignTop); |
|
421 | 423 | } else { |
|
422 | 424 | qWarning() << "Trying to set axisXTop to null."; |
|
423 | 425 | } |
|
424 | 426 | } |
|
425 | 427 | |
|
426 | 428 | void DeclarativeChart::handleAxisYSet(QAbstractAxis *axis) |
|
427 | 429 | { |
|
428 | 430 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
429 | 431 | if (axis && s) { |
|
430 | 432 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignLeft); |
|
431 | 433 | } else { |
|
432 | 434 | qWarning() << "Trying to set axisY to null."; |
|
433 | 435 | } |
|
434 | 436 | } |
|
435 | 437 | |
|
436 | 438 | void DeclarativeChart::handleAxisYRightSet(QAbstractAxis *axis) |
|
437 | 439 | { |
|
438 | 440 | QAbstractSeries *s = qobject_cast<QAbstractSeries *>(sender()); |
|
439 | 441 | if (axis && s) { |
|
440 | 442 | seriesAxisAttachHelper(s, axis, Qt::Vertical, Qt::AlignRight); |
|
441 | 443 | } else { |
|
442 | 444 | qWarning() << "Trying to set axisYRight to null."; |
|
443 | 445 | } |
|
444 | 446 | } |
|
445 | 447 | |
|
446 | 448 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
447 | 449 | { |
|
448 | 450 | if (newGeometry.isValid()) { |
|
449 | 451 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
450 | 452 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
451 | 453 | } |
|
452 | 454 | } |
|
453 | 455 | QQuickItem::geometryChanged(newGeometry, oldGeometry); |
|
454 | 456 | } |
|
455 | 457 | |
|
456 | 458 | void DeclarativeChart::sceneChanged(QList<QRectF> region) |
|
457 | 459 | { |
|
458 | 460 | Q_UNUSED(region); |
|
459 | 461 | |
|
460 | 462 | if (m_guiThreadId == m_paintThreadId) { |
|
461 | 463 | // Rendering in gui thread, no need for shenannigans, just update |
|
462 | 464 | update(); |
|
463 | 465 | } else { |
|
464 | 466 | // Multi-threaded rendering, need to ensure scene is actually rendered in gui thread |
|
465 | 467 | if (!m_updatePending) { |
|
466 | 468 | m_updatePending = true; |
|
467 | 469 | // Do async render to avoid some unnecessary renders. |
|
468 | 470 | QTimer::singleShot(0, this, SLOT(renderScene())); |
|
469 | 471 | } |
|
470 | 472 | } |
|
471 | 473 | } |
|
472 | 474 | |
|
473 | 475 | void DeclarativeChart::renderScene() |
|
474 | 476 | { |
|
475 | 477 | m_updatePending = false; |
|
476 | 478 | m_sceneImageLock.lock(); |
|
477 | 479 | delete m_currentSceneImage; |
|
478 | 480 | m_currentSceneImage = new QImage(m_chart->size().toSize(), QImage::Format_ARGB32); |
|
479 | 481 | m_currentSceneImage->fill(Qt::transparent); |
|
480 | 482 | QPainter painter(m_currentSceneImage); |
|
481 | 483 | if (antialiasing()) |
|
482 | 484 | painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); |
|
483 | 485 | QRect renderRect(QPoint(0, 0), m_chart->size().toSize()); |
|
484 | 486 | m_scene->render(&painter, renderRect, renderRect); |
|
485 | 487 | m_sceneImageLock.unlock(); |
|
486 | 488 | |
|
487 | 489 | update(); |
|
488 | 490 | } |
|
489 | 491 | |
|
490 | 492 | void DeclarativeChart::paint(QPainter *painter) |
|
491 | 493 | { |
|
492 | 494 | if (!m_paintThreadId) { |
|
493 | 495 | m_paintThreadId = QThread::currentThreadId(); |
|
494 | 496 | if (m_guiThreadId == m_paintThreadId) { |
|
495 | 497 | // No need for scene image in single threaded rendering, so delete |
|
496 | 498 | // the one that got made by default before the rendering type was |
|
497 | 499 | // detected. |
|
498 | 500 | delete m_currentSceneImage; |
|
499 | 501 | m_currentSceneImage = 0; |
|
500 | 502 | } |
|
501 | 503 | } |
|
502 | 504 | |
|
503 | 505 | if (m_guiThreadId == m_paintThreadId) { |
|
504 | 506 | QRectF renderRect(QPointF(0, 0), m_chart->size()); |
|
505 | 507 | m_scene->render(painter, renderRect, renderRect); |
|
506 | 508 | } else { |
|
507 | 509 | m_sceneImageLock.lock(); |
|
508 | 510 | if (m_currentSceneImage) { |
|
509 | 511 | QRect imageRect(QPoint(0, 0), m_currentSceneImage->size()); |
|
510 | 512 | QRect itemRect(QPoint(0, 0), QSize(width(), height())); |
|
511 | 513 | painter->drawImage(itemRect, *m_currentSceneImage, imageRect); |
|
512 | 514 | } |
|
513 | 515 | m_sceneImageLock.unlock(); |
|
514 | 516 | } |
|
515 | 517 | } |
|
516 | 518 | |
|
517 | 519 | void DeclarativeChart::mousePressEvent(QMouseEvent *event) |
|
518 | 520 | { |
|
519 | 521 | m_mousePressScenePoint = event->pos(); |
|
520 | 522 | m_mousePressScreenPoint = event->globalPos(); |
|
521 | 523 | m_lastMouseMoveScenePoint = m_mousePressScenePoint; |
|
522 | 524 | m_lastMouseMoveScreenPoint = m_mousePressScreenPoint; |
|
523 | 525 | m_mousePressButton = event->button(); |
|
524 | 526 | m_mousePressButtons = event->buttons(); |
|
525 | 527 | |
|
526 | 528 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress); |
|
527 | 529 | mouseEvent.setWidget(0); |
|
528 | 530 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
529 | 531 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
530 | 532 | mouseEvent.setScenePos(m_mousePressScenePoint); |
|
531 | 533 | mouseEvent.setScreenPos(m_mousePressScreenPoint); |
|
532 | 534 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
533 | 535 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
534 | 536 | mouseEvent.setButtons(m_mousePressButtons); |
|
535 | 537 | mouseEvent.setButton(m_mousePressButton); |
|
536 | 538 | mouseEvent.setModifiers(event->modifiers()); |
|
537 | 539 | mouseEvent.setAccepted(false); |
|
538 | 540 | |
|
539 | 541 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
540 | 542 | } |
|
541 | 543 | |
|
542 | 544 | void DeclarativeChart::mouseReleaseEvent(QMouseEvent *event) |
|
543 | 545 | { |
|
544 | 546 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease); |
|
545 | 547 | mouseEvent.setWidget(0); |
|
546 | 548 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
547 | 549 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
548 | 550 | mouseEvent.setScenePos(event->pos()); |
|
549 | 551 | mouseEvent.setScreenPos(event->globalPos()); |
|
550 | 552 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
551 | 553 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
552 | 554 | mouseEvent.setButtons(event->buttons()); |
|
553 | 555 | mouseEvent.setButton(event->button()); |
|
554 | 556 | mouseEvent.setModifiers(event->modifiers()); |
|
555 | 557 | mouseEvent.setAccepted(false); |
|
556 | 558 | |
|
557 | 559 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
558 | 560 | |
|
559 | 561 | m_mousePressButtons = event->buttons(); |
|
560 | 562 | m_mousePressButton = Qt::NoButton; |
|
561 | 563 | } |
|
562 | 564 | |
|
563 | 565 | void DeclarativeChart::hoverMoveEvent(QHoverEvent *event) |
|
564 | 566 | { |
|
565 | 567 | // Convert hover move to mouse move, since we don't seem to get actual mouse move events. |
|
566 | 568 | // QGraphicsScene generates hover events from mouse move events, so we don't need |
|
567 | 569 | // to pass hover events there. |
|
568 | 570 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); |
|
569 | 571 | mouseEvent.setWidget(0); |
|
570 | 572 | mouseEvent.setButtonDownScenePos(m_mousePressButton, m_mousePressScenePoint); |
|
571 | 573 | mouseEvent.setButtonDownScreenPos(m_mousePressButton, m_mousePressScreenPoint); |
|
572 | 574 | mouseEvent.setScenePos(event->pos()); |
|
573 | 575 | // Hover events do not have global pos in them, and the screen position doesn't seem to |
|
574 | 576 | // matter anyway in this use case, so just pass event pos instead of trying to |
|
575 | 577 | // calculate the real screen position. |
|
576 | 578 | mouseEvent.setScreenPos(event->pos()); |
|
577 | 579 | mouseEvent.setLastScenePos(m_lastMouseMoveScenePoint); |
|
578 | 580 | mouseEvent.setLastScreenPos(m_lastMouseMoveScreenPoint); |
|
579 | 581 | mouseEvent.setButtons(m_mousePressButtons); |
|
580 | 582 | mouseEvent.setButton(m_mousePressButton); |
|
581 | 583 | mouseEvent.setModifiers(event->modifiers()); |
|
582 | 584 | m_lastMouseMoveScenePoint = mouseEvent.scenePos(); |
|
583 | 585 | m_lastMouseMoveScreenPoint = mouseEvent.screenPos(); |
|
584 | 586 | mouseEvent.setAccepted(false); |
|
585 | 587 | |
|
586 | 588 | QApplication::sendEvent(m_scene, &mouseEvent); |
|
587 | 589 | } |
|
588 | 590 | |
|
589 | 591 | void DeclarativeChart::handleAntialiasingChanged(bool enable) |
|
590 | 592 | { |
|
591 | 593 | setAntialiasing(enable); |
|
592 | 594 | } |
|
593 | 595 | |
|
594 | 596 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
595 | 597 | { |
|
596 | 598 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
597 | 599 | if (chartTheme != m_chart->theme()) |
|
598 | 600 | m_chart->setTheme(chartTheme); |
|
599 | 601 | } |
|
600 | 602 | |
|
601 | 603 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
602 | 604 | { |
|
603 | 605 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
604 | 606 | } |
|
605 | 607 | |
|
606 | 608 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
607 | 609 | { |
|
608 | 610 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
609 | 611 | if (animationOptions != m_chart->animationOptions()) |
|
610 | 612 | m_chart->setAnimationOptions(animationOptions); |
|
611 | 613 | } |
|
612 | 614 | |
|
613 | 615 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
614 | 616 | { |
|
615 | 617 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
616 | 618 | return DeclarativeChart::AllAnimations; |
|
617 | 619 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
618 | 620 | return DeclarativeChart::GridAxisAnimations; |
|
619 | 621 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
620 | 622 | return DeclarativeChart::SeriesAnimations; |
|
621 | 623 | else |
|
622 | 624 | return DeclarativeChart::NoAnimation; |
|
623 | 625 | } |
|
624 | 626 | |
|
625 | 627 | void DeclarativeChart::setTitle(QString title) |
|
626 | 628 | { |
|
627 | 629 | if (title != m_chart->title()) |
|
628 | 630 | m_chart->setTitle(title); |
|
629 | 631 | } |
|
630 | 632 | QString DeclarativeChart::title() |
|
631 | 633 | { |
|
632 | 634 | return m_chart->title(); |
|
633 | 635 | } |
|
634 | 636 | |
|
635 | 637 | QAbstractAxis *DeclarativeChart::axisX(QAbstractSeries *series) |
|
636 | 638 | { |
|
637 | 639 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Horizontal, series); |
|
638 | 640 | if (axes.count()) |
|
639 | 641 | return axes[0]; |
|
640 | 642 | return 0; |
|
641 | 643 | } |
|
642 | 644 | |
|
643 | 645 | QAbstractAxis *DeclarativeChart::axisY(QAbstractSeries *series) |
|
644 | 646 | { |
|
645 | 647 | QList<QAbstractAxis *> axes = m_chart->axes(Qt::Vertical, series); |
|
646 | 648 | if (axes.count()) |
|
647 | 649 | return axes[0]; |
|
648 | 650 | return 0; |
|
649 | 651 | } |
|
650 | 652 | |
|
651 | 653 | QLegend *DeclarativeChart::legend() |
|
652 | 654 | { |
|
653 | 655 | return m_chart->legend(); |
|
654 | 656 | } |
|
655 | 657 | |
|
656 | 658 | void DeclarativeChart::setTitleColor(QColor color) |
|
657 | 659 | { |
|
658 | 660 | QBrush b = m_chart->titleBrush(); |
|
659 | 661 | if (color != b.color()) { |
|
660 | 662 | b.setColor(color); |
|
661 | 663 | m_chart->setTitleBrush(b); |
|
662 | 664 | emit titleColorChanged(color); |
|
663 | 665 | } |
|
664 | 666 | } |
|
665 | 667 | |
|
666 | 668 | QFont DeclarativeChart::titleFont() const |
|
667 | 669 | { |
|
668 | 670 | return m_chart->titleFont(); |
|
669 | 671 | } |
|
670 | 672 | |
|
671 | 673 | void DeclarativeChart::setTitleFont(const QFont &font) |
|
672 | 674 | { |
|
673 | 675 | m_chart->setTitleFont(font); |
|
674 | 676 | } |
|
675 | 677 | |
|
676 | 678 | QColor DeclarativeChart::titleColor() |
|
677 | 679 | { |
|
678 | 680 | return m_chart->titleBrush().color(); |
|
679 | 681 | } |
|
680 | 682 | |
|
681 | 683 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
682 | 684 | { |
|
683 | 685 | QBrush b = m_chart->backgroundBrush(); |
|
684 | 686 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
685 | 687 | b.setStyle(Qt::SolidPattern); |
|
686 | 688 | b.setColor(color); |
|
687 | 689 | m_chart->setBackgroundBrush(b); |
|
688 | 690 | emit backgroundColorChanged(); |
|
689 | 691 | } |
|
690 | 692 | } |
|
691 | 693 | |
|
692 | 694 | QColor DeclarativeChart::backgroundColor() |
|
693 | 695 | { |
|
694 | 696 | return m_chart->backgroundBrush().color(); |
|
695 | 697 | } |
|
696 | 698 | |
|
697 | 699 | void QtCharts::DeclarativeChart::setPlotAreaColor(QColor color) |
|
698 | 700 | { |
|
699 | 701 | QBrush b = m_chart->plotAreaBackgroundBrush(); |
|
700 | 702 | if (b.style() != Qt::SolidPattern || color != b.color()) { |
|
701 | 703 | b.setStyle(Qt::SolidPattern); |
|
702 | 704 | b.setColor(color); |
|
703 | 705 | m_chart->setPlotAreaBackgroundBrush(b); |
|
704 | 706 | m_chart->setPlotAreaBackgroundVisible(true); |
|
705 | 707 | emit plotAreaColorChanged(); |
|
706 | 708 | } |
|
707 | 709 | } |
|
708 | 710 | |
|
709 | 711 | QColor QtCharts::DeclarativeChart::plotAreaColor() |
|
710 | 712 | { |
|
711 | 713 | return m_chart->plotAreaBackgroundBrush().color(); |
|
712 | 714 | } |
|
713 | 715 | |
|
714 | 716 | void DeclarativeChart::setLocalizeNumbers(bool localize) |
|
715 | 717 | { |
|
716 | 718 | if (m_chart->localizeNumbers() != localize) { |
|
717 | 719 | m_chart->setLocalizeNumbers(localize); |
|
718 | 720 | emit localizeNumbersChanged(); |
|
719 | 721 | } |
|
720 | 722 | } |
|
721 | 723 | |
|
722 | 724 | bool DeclarativeChart::localizeNumbers() const |
|
723 | 725 | { |
|
724 | 726 | return m_chart->localizeNumbers(); |
|
725 | 727 | } |
|
726 | 728 | |
|
727 | 729 | void QtCharts::DeclarativeChart::setLocale(const QLocale &locale) |
|
728 | 730 | { |
|
729 | 731 | if (m_chart->locale() != locale) { |
|
730 | 732 | m_chart->setLocale(locale); |
|
731 | 733 | emit localeChanged(); |
|
732 | 734 | } |
|
733 | 735 | } |
|
734 | 736 | |
|
735 | 737 | QLocale QtCharts::DeclarativeChart::locale() const |
|
736 | 738 | { |
|
737 | 739 | return m_chart->locale(); |
|
738 | 740 | } |
|
739 | 741 | |
|
740 | 742 | int DeclarativeChart::count() |
|
741 | 743 | { |
|
742 | 744 | return m_chart->series().count(); |
|
743 | 745 | } |
|
744 | 746 | |
|
745 | 747 | void DeclarativeChart::setDropShadowEnabled(bool enabled) |
|
746 | 748 | { |
|
747 | 749 | if (enabled != m_chart->isDropShadowEnabled()) { |
|
748 | 750 | m_chart->setDropShadowEnabled(enabled); |
|
749 | 751 | dropShadowEnabledChanged(enabled); |
|
750 | 752 | } |
|
751 | 753 | } |
|
752 | 754 | |
|
753 | 755 | bool DeclarativeChart::dropShadowEnabled() |
|
754 | 756 | { |
|
755 | 757 | return m_chart->isDropShadowEnabled(); |
|
756 | 758 | } |
|
757 | 759 | |
|
758 | 760 | qreal DeclarativeChart::backgroundRoundness() const |
|
759 | 761 | { |
|
760 | 762 | return m_chart->backgroundRoundness(); |
|
761 | 763 | } |
|
762 | 764 | |
|
763 | 765 | void DeclarativeChart::setBackgroundRoundness(qreal diameter) |
|
764 | 766 | { |
|
765 | 767 | if (m_chart->backgroundRoundness() != diameter) { |
|
766 | 768 | m_chart->setBackgroundRoundness(diameter); |
|
767 | 769 | emit backgroundRoundnessChanged(diameter); |
|
768 | 770 | } |
|
769 | 771 | } |
|
770 | 772 | |
|
771 | 773 | qreal DeclarativeChart::topMargin() |
|
772 | 774 | { |
|
773 | 775 | qWarning() << "ChartView.topMargin is deprecated. Use margins instead."; |
|
774 | 776 | return m_chart->margins().top(); |
|
775 | 777 | } |
|
776 | 778 | |
|
777 | 779 | qreal DeclarativeChart::bottomMargin() |
|
778 | 780 | { |
|
779 | 781 | qWarning() << "ChartView.bottomMargin is deprecated. Use margins instead."; |
|
780 | 782 | return m_chart->margins().bottom(); |
|
781 | 783 | } |
|
782 | 784 | |
|
783 | 785 | qreal DeclarativeChart::leftMargin() |
|
784 | 786 | { |
|
785 | 787 | qWarning() << "ChartView.leftMargin is deprecated. Use margins instead."; |
|
786 | 788 | return m_chart->margins().left(); |
|
787 | 789 | } |
|
788 | 790 | |
|
789 | 791 | qreal DeclarativeChart::rightMargin() |
|
790 | 792 | { |
|
791 | 793 | qWarning() << "ChartView.rightMargin is deprecated. Use margins instead."; |
|
792 | 794 | return m_chart->margins().right(); |
|
793 | 795 | } |
|
794 | 796 | |
|
795 | 797 | void DeclarativeChart::zoom(qreal factor) |
|
796 | 798 | { |
|
797 | 799 | m_chart->zoom(factor); |
|
798 | 800 | } |
|
799 | 801 | |
|
800 | 802 | void DeclarativeChart::scrollLeft(qreal pixels) |
|
801 | 803 | { |
|
802 | 804 | m_chart->scroll(-pixels, 0); |
|
803 | 805 | } |
|
804 | 806 | |
|
805 | 807 | void DeclarativeChart::scrollRight(qreal pixels) |
|
806 | 808 | { |
|
807 | 809 | m_chart->scroll(pixels, 0); |
|
808 | 810 | } |
|
809 | 811 | |
|
810 | 812 | void DeclarativeChart::scrollUp(qreal pixels) |
|
811 | 813 | { |
|
812 | 814 | m_chart->scroll(0, pixels); |
|
813 | 815 | } |
|
814 | 816 | |
|
815 | 817 | void DeclarativeChart::scrollDown(qreal pixels) |
|
816 | 818 | { |
|
817 | 819 | m_chart->scroll(0, -pixels); |
|
818 | 820 | } |
|
819 | 821 | |
|
820 | 822 | QQmlListProperty<QAbstractAxis> DeclarativeChart::axes() |
|
821 | 823 | { |
|
822 | 824 | return QQmlListProperty<QAbstractAxis>(this, 0, |
|
823 | 825 | &DeclarativeChart::axesAppendFunc, |
|
824 | 826 | &DeclarativeChart::axesCountFunc, |
|
825 | 827 | &DeclarativeChart::axesAtFunc, |
|
826 | 828 | &DeclarativeChart::axesClearFunc); |
|
827 | 829 | } |
|
828 | 830 | |
|
829 | 831 | void DeclarativeChart::axesAppendFunc(QQmlListProperty<QAbstractAxis> *list, QAbstractAxis *element) |
|
830 | 832 | { |
|
831 | 833 | // Empty implementation |
|
832 | 834 | Q_UNUSED(list); |
|
833 | 835 | Q_UNUSED(element); |
|
834 | 836 | } |
|
835 | 837 | |
|
836 | 838 | int DeclarativeChart::axesCountFunc(QQmlListProperty<QAbstractAxis> *list) |
|
837 | 839 | { |
|
838 | 840 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
839 | 841 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
840 | 842 | return chart->m_chart->axes(Qt::Horizontal | Qt::Vertical).count(); |
|
841 | 843 | } |
|
842 | 844 | return 0; |
|
843 | 845 | } |
|
844 | 846 | |
|
845 | 847 | QAbstractAxis *DeclarativeChart::axesAtFunc(QQmlListProperty<QAbstractAxis> *list, int index) |
|
846 | 848 | { |
|
847 | 849 | if (qobject_cast<DeclarativeChart *>(list->object)) { |
|
848 | 850 | DeclarativeChart *chart = qobject_cast<DeclarativeChart *>(list->object); |
|
849 | 851 | QList<QAbstractAxis *> axes = chart->m_chart->axes(Qt::Horizontal | Qt::Vertical, chart->m_chart->series()[0]); |
|
850 | 852 | return axes.at(index); |
|
851 | 853 | } |
|
852 | 854 | return 0; |
|
853 | 855 | } |
|
854 | 856 | |
|
855 | 857 | void DeclarativeChart::axesClearFunc(QQmlListProperty<QAbstractAxis> *list) |
|
856 | 858 | { |
|
857 | 859 | // Empty implementation |
|
858 | 860 | Q_UNUSED(list); |
|
859 | 861 | } |
|
860 | 862 | |
|
861 | 863 | |
|
862 | 864 | QAbstractSeries *DeclarativeChart::series(int index) |
|
863 | 865 | { |
|
864 | 866 | if (index < m_chart->series().count()) { |
|
865 | 867 | return m_chart->series().at(index); |
|
866 | 868 | } |
|
867 | 869 | return 0; |
|
868 | 870 | } |
|
869 | 871 | |
|
870 | 872 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
871 | 873 | { |
|
872 | 874 | foreach (QAbstractSeries *series, m_chart->series()) { |
|
873 | 875 | if (series->name() == seriesName) |
|
874 | 876 | return series; |
|
875 | 877 | } |
|
876 | 878 | return 0; |
|
877 | 879 | } |
|
878 | 880 | |
|
879 | 881 | QAbstractSeries *DeclarativeChart::createSeries(int type, QString name, QAbstractAxis *axisX, QAbstractAxis *axisY) |
|
880 | 882 | { |
|
881 | 883 | QAbstractSeries *series = 0; |
|
882 | 884 | |
|
883 | 885 | switch (type) { |
|
884 | 886 | case DeclarativeChart::SeriesTypeLine: |
|
885 | 887 | series = new DeclarativeLineSeries(); |
|
886 | 888 | break; |
|
887 | 889 | case DeclarativeChart::SeriesTypeArea: { |
|
888 | 890 | DeclarativeAreaSeries *area = new DeclarativeAreaSeries(); |
|
889 | 891 | area->setUpperSeries(new DeclarativeLineSeries()); |
|
890 | 892 | series = area; |
|
891 | 893 | break; |
|
892 | 894 | } |
|
893 | 895 | case DeclarativeChart::SeriesTypeStackedBar: |
|
894 | 896 | series = new DeclarativeStackedBarSeries(); |
|
895 | 897 | break; |
|
896 | 898 | case DeclarativeChart::SeriesTypePercentBar: |
|
897 | 899 | series = new DeclarativePercentBarSeries(); |
|
898 | 900 | break; |
|
899 | 901 | case DeclarativeChart::SeriesTypeBar: |
|
900 | 902 | series = new DeclarativeBarSeries(); |
|
901 | 903 | break; |
|
902 | 904 | case DeclarativeChart::SeriesTypeHorizontalBar: |
|
903 | 905 | series = new DeclarativeHorizontalBarSeries(); |
|
904 | 906 | break; |
|
905 | 907 | case DeclarativeChart::SeriesTypeHorizontalPercentBar: |
|
906 | 908 | series = new DeclarativeHorizontalPercentBarSeries(); |
|
907 | 909 | break; |
|
908 | 910 | case DeclarativeChart::SeriesTypeHorizontalStackedBar: |
|
909 | 911 | series = new DeclarativeHorizontalStackedBarSeries(); |
|
910 | 912 | break; |
|
911 | 913 | case DeclarativeChart::SeriesTypeBoxPlot: |
|
912 | 914 | series = new DeclarativeBoxPlotSeries(); |
|
913 | 915 | break; |
|
914 | 916 | case DeclarativeChart::SeriesTypePie: |
|
915 | 917 | series = new DeclarativePieSeries(); |
|
916 | 918 | break; |
|
917 | 919 | case DeclarativeChart::SeriesTypeScatter: |
|
918 | 920 | series = new DeclarativeScatterSeries(); |
|
919 | 921 | break; |
|
920 | 922 | case DeclarativeChart::SeriesTypeSpline: |
|
921 | 923 | series = new DeclarativeSplineSeries(); |
|
922 | 924 | break; |
|
923 | 925 | default: |
|
924 | 926 | qWarning() << "Illegal series type"; |
|
925 | 927 | } |
|
926 | 928 | |
|
927 | 929 | if (series) { |
|
928 | 930 | // Connect to axis changed signals (unless this is a pie series) |
|
929 | 931 | if (!qobject_cast<DeclarativePieSeries *>(series)) { |
|
930 | 932 | connect(series, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
931 | 933 | connect(series, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); |
|
932 | 934 | connect(series, SIGNAL(axisYChanged(QAbstractAxis*)), this, SLOT(handleAxisYSet(QAbstractAxis*))); |
|
933 | 935 | connect(series, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SLOT(handleAxisYRightSet(QAbstractAxis*))); |
|
934 | 936 | } |
|
935 | 937 | |
|
936 | 938 | series->setName(name); |
|
937 | 939 | m_chart->addSeries(series); |
|
938 | 940 | |
|
939 | 941 | if (!axisX || !axisY) |
|
940 | 942 | initializeAxes(series); |
|
941 | 943 | |
|
942 | 944 | if (axisX) |
|
943 | 945 | setAxisX(axisX, series); |
|
944 | 946 | if (axisY) |
|
945 | 947 | setAxisY(axisY, series); |
|
946 | 948 | } |
|
947 | 949 | |
|
948 | 950 | return series; |
|
949 | 951 | } |
|
950 | 952 | |
|
951 | 953 | void DeclarativeChart::removeSeries(QAbstractSeries *series) |
|
952 | 954 | { |
|
953 | 955 | if (series) |
|
954 | 956 | m_chart->removeSeries(series); |
|
955 | 957 | else |
|
956 | 958 | qWarning("removeSeries: cannot remove null"); |
|
957 | 959 | } |
|
958 | 960 | |
|
959 | 961 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) |
|
960 | 962 | { |
|
961 | 963 | if (axis && series) |
|
962 | 964 | seriesAxisAttachHelper(series, axis, Qt::Horizontal, Qt::AlignBottom); |
|
963 | 965 | } |
|
964 | 966 | |
|
965 | 967 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) |
|
966 | 968 | { |
|
967 | 969 | if (axis && series) |
|
968 | 970 | seriesAxisAttachHelper(series, axis, Qt::Vertical, Qt::AlignLeft); |
|
969 | 971 | } |
|
970 | 972 | |
|
971 | 973 | void DeclarativeChart::createDefaultAxes() |
|
972 | 974 | { |
|
973 | 975 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; |
|
974 | 976 | } |
|
975 | 977 | |
|
976 | 978 | QAbstractAxis *DeclarativeChart::defaultAxis(Qt::Orientation orientation, QAbstractSeries *series) |
|
977 | 979 | { |
|
978 | 980 | if (!series) { |
|
979 | 981 | qWarning() << "No axis type defined for null series"; |
|
980 | 982 | return 0; |
|
981 | 983 | } |
|
982 | 984 | |
|
983 | 985 | foreach (QAbstractAxis *existingAxis, m_chart->axes(orientation)) { |
|
984 | 986 | if (existingAxis->type() == series->d_ptr->defaultAxisType(orientation)) |
|
985 | 987 | return existingAxis; |
|
986 | 988 | } |
|
987 | 989 | |
|
988 | 990 | switch (series->d_ptr->defaultAxisType(orientation)) { |
|
989 | 991 | case QAbstractAxis::AxisTypeValue: |
|
990 | 992 | return new QValueAxis(this); |
|
991 | 993 | case QAbstractAxis::AxisTypeBarCategory: |
|
992 | 994 | return new QBarCategoryAxis(this); |
|
993 | 995 | case QAbstractAxis::AxisTypeCategory: |
|
994 | 996 | return new QCategoryAxis(this); |
|
995 | 997 | #ifndef QT_ON_ARM |
|
996 | 998 | case QAbstractAxis::AxisTypeDateTime: |
|
997 | 999 | return new QDateTimeAxis(this); |
|
998 | 1000 | #endif |
|
999 | 1001 | case QAbstractAxis::AxisTypeLogValue: |
|
1000 | 1002 | return new QLogValueAxis(this); |
|
1001 | 1003 | default: |
|
1002 | 1004 | // assume AxisTypeNoAxis |
|
1003 | 1005 | return 0; |
|
1004 | 1006 | } |
|
1005 | 1007 | } |
|
1006 | 1008 | |
|
1007 | 1009 | void DeclarativeChart::initializeAxes(QAbstractSeries *series) |
|
1008 | 1010 | { |
|
1009 | 1011 | if (qobject_cast<DeclarativeLineSeries *>(series)) |
|
1010 | 1012 | doInitializeAxes(series, qobject_cast<DeclarativeLineSeries *>(series)->m_axes); |
|
1011 | 1013 | else if (qobject_cast<DeclarativeScatterSeries *>(series)) |
|
1012 | 1014 | doInitializeAxes(series, qobject_cast<DeclarativeScatterSeries *>(series)->m_axes); |
|
1013 | 1015 | else if (qobject_cast<DeclarativeSplineSeries *>(series)) |
|
1014 | 1016 | doInitializeAxes(series, qobject_cast<DeclarativeSplineSeries *>(series)->m_axes); |
|
1015 | 1017 | else if (qobject_cast<DeclarativeAreaSeries *>(series)) |
|
1016 | 1018 | doInitializeAxes(series, qobject_cast<DeclarativeAreaSeries *>(series)->m_axes); |
|
1017 | 1019 | else if (qobject_cast<DeclarativeBarSeries *>(series)) |
|
1018 | 1020 | doInitializeAxes(series, qobject_cast<DeclarativeBarSeries *>(series)->m_axes); |
|
1019 | 1021 | else if (qobject_cast<DeclarativeStackedBarSeries *>(series)) |
|
1020 | 1022 | doInitializeAxes(series, qobject_cast<DeclarativeStackedBarSeries *>(series)->m_axes); |
|
1021 | 1023 | else if (qobject_cast<DeclarativePercentBarSeries *>(series)) |
|
1022 | 1024 | doInitializeAxes(series, qobject_cast<DeclarativePercentBarSeries *>(series)->m_axes); |
|
1023 | 1025 | else if (qobject_cast<DeclarativeHorizontalBarSeries *>(series)) |
|
1024 | 1026 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalBarSeries *>(series)->m_axes); |
|
1025 | 1027 | else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)) |
|
1026 | 1028 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalStackedBarSeries *>(series)->m_axes); |
|
1027 | 1029 | else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)) |
|
1028 | 1030 | doInitializeAxes(series, qobject_cast<DeclarativeHorizontalPercentBarSeries *>(series)->m_axes); |
|
1029 | 1031 | else if (qobject_cast<DeclarativeBoxPlotSeries *>(series)) |
|
1030 | 1032 | doInitializeAxes(series, qobject_cast<DeclarativeBoxPlotSeries *>(series)->m_axes); |
|
1031 | 1033 | // else: do nothing |
|
1032 | 1034 | } |
|
1033 | 1035 | |
|
1034 | 1036 | void DeclarativeChart::doInitializeAxes(QAbstractSeries *series, DeclarativeAxes *axes) |
|
1035 | 1037 | { |
|
1036 | 1038 | // Initialize axis X |
|
1037 | 1039 | if (axes->axisX()) |
|
1038 | 1040 | axes->emitAxisXChanged(); |
|
1039 | 1041 | else if (axes->axisXTop()) |
|
1040 | 1042 | axes->emitAxisXTopChanged(); |
|
1041 | 1043 | else |
|
1042 | 1044 | axes->setAxisX(defaultAxis(Qt::Horizontal, series)); |
|
1043 | 1045 | |
|
1044 | 1046 | // Initialize axis Y |
|
1045 | 1047 | if (axes->axisY()) |
|
1046 | 1048 | axes->emitAxisYChanged(); |
|
1047 | 1049 | else if (axes->axisYRight()) |
|
1048 | 1050 | axes->emitAxisYRightChanged(); |
|
1049 | 1051 | else |
|
1050 | 1052 | axes->setAxisY(defaultAxis(Qt::Vertical, series)); |
|
1051 | 1053 | } |
|
1052 | 1054 | |
|
1053 | 1055 | #include "moc_declarativechart.cpp" |
|
1054 | 1056 | |
|
1055 | 1057 | QT_CHARTS_END_NAMESPACE |
@@ -1,113 +1,115 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativemargins.h" |
|
22 | 22 | #include <QtCore/QDataStream> |
|
23 | 23 | #include <QtCore/QDebug> |
|
24 | 24 | |
|
25 | 25 | QT_CHARTS_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | /*! |
|
28 | 28 | \qmltype Margins |
|
29 | 29 | \inqmlmodule QtCharts |
|
30 | 30 | |
|
31 | \brief Type is used to define margins. | |
|
32 | ||
|
31 | 33 | Uncreatable type that is used to define top, bottom, left and right margins. |
|
32 | 34 | */ |
|
33 | 35 | |
|
34 | 36 | /*! |
|
35 | 37 | \qmlproperty int Margins::top |
|
36 | 38 | The top margin. |
|
37 | 39 | */ |
|
38 | 40 | |
|
39 | 41 | /*! |
|
40 | 42 | \qmlproperty int Margins::bottom |
|
41 | 43 | The bottom margin. |
|
42 | 44 | */ |
|
43 | 45 | |
|
44 | 46 | /*! |
|
45 | 47 | \qmlproperty int Margins::left |
|
46 | 48 | The left margin. |
|
47 | 49 | */ |
|
48 | 50 | |
|
49 | 51 | /*! |
|
50 | 52 | \qmlproperty int Margins::right |
|
51 | 53 | The right margin. |
|
52 | 54 | */ |
|
53 | 55 | |
|
54 | 56 | DeclarativeMargins::DeclarativeMargins(QObject *parent) : |
|
55 | 57 | QObject(parent) |
|
56 | 58 | { |
|
57 | 59 | QMargins::setTop(0); |
|
58 | 60 | QMargins::setBottom(0); |
|
59 | 61 | QMargins::setLeft(0); |
|
60 | 62 | QMargins::setRight(0); |
|
61 | 63 | } |
|
62 | 64 | |
|
63 | 65 | void DeclarativeMargins::setTop(int top) |
|
64 | 66 | { |
|
65 | 67 | if (top < 0) { |
|
66 | 68 | qWarning() << "Cannot set top margin to a negative value:" << top; |
|
67 | 69 | } else { |
|
68 | 70 | if (top != QMargins::top()) { |
|
69 | 71 | QMargins::setTop(top); |
|
70 | 72 | emit topChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); |
|
71 | 73 | } |
|
72 | 74 | } |
|
73 | 75 | } |
|
74 | 76 | |
|
75 | 77 | void DeclarativeMargins::setBottom(int bottom) |
|
76 | 78 | { |
|
77 | 79 | if (bottom < 0) { |
|
78 | 80 | qWarning() << "Cannot set bottom margin to a negative value:" << bottom; |
|
79 | 81 | } else { |
|
80 | 82 | if (bottom != QMargins::bottom()) { |
|
81 | 83 | QMargins::setBottom(bottom); |
|
82 | 84 | emit bottomChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); |
|
83 | 85 | } |
|
84 | 86 | } |
|
85 | 87 | } |
|
86 | 88 | |
|
87 | 89 | void DeclarativeMargins::setLeft(int left) |
|
88 | 90 | { |
|
89 | 91 | if (left < 0) { |
|
90 | 92 | qWarning() << "Cannot set left margin to a negative value:" << left; |
|
91 | 93 | } else { |
|
92 | 94 | if (left != QMargins::left()) { |
|
93 | 95 | QMargins::setLeft(left); |
|
94 | 96 | emit leftChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); |
|
95 | 97 | } |
|
96 | 98 | } |
|
97 | 99 | } |
|
98 | 100 | |
|
99 | 101 | void DeclarativeMargins::setRight(int right) |
|
100 | 102 | { |
|
101 | 103 | if (right < 0) { |
|
102 | 104 | qWarning() << "Cannot set left margin to a negative value:" << right; |
|
103 | 105 | } else { |
|
104 | 106 | if (right != QMargins::right()) { |
|
105 | 107 | QMargins::setRight(right); |
|
106 | 108 | emit rightChanged(QMargins::top(), QMargins::bottom(), QMargins::left(), QMargins::right()); |
|
107 | 109 | } |
|
108 | 110 | } |
|
109 | 111 | } |
|
110 | 112 | |
|
111 | 113 | #include "moc_declarativemargins.cpp" |
|
112 | 114 | |
|
113 | 115 | QT_CHARTS_END_NAMESPACE |
@@ -1,64 +1,66 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativepolarchart.h" |
|
22 | 22 | #include <QtCharts/QChart> |
|
23 | 23 | |
|
24 | 24 | QT_CHARTS_BEGIN_NAMESPACE |
|
25 | 25 | |
|
26 | 26 | /*! |
|
27 | 27 | \qmltype PolarChartView |
|
28 | 28 | \instantiates DeclarativePolarChart |
|
29 | 29 | \inqmlmodule QtCharts |
|
30 | 30 | |
|
31 | \brief Polar chart element. | |
|
32 | ||
|
31 | 33 | PolarChartView element is the parent that is responsible for showing different chart series |
|
32 | 34 | types in a polar chart. |
|
33 | 35 | |
|
34 | 36 | Polar charts support line, spline, area, and scatter series, and all axis types |
|
35 | 37 | supported by those series. |
|
36 | 38 | |
|
37 | 39 | \note When setting ticks to an angular ValueAxis, keep in mind that the first and last tick |
|
38 | 40 | are co-located at 0/360 degree angle. |
|
39 | 41 | |
|
40 | 42 | \note If the angular distance between two consecutive points in a series is more than 180 |
|
41 | 43 | degrees, any line connecting the two points becomes meaningless, so choose the axis ranges |
|
42 | 44 | accordingly when displaying line, spline, or area series. |
|
43 | 45 | |
|
44 | 46 | The following QML shows how to create a polar chart with two series: |
|
45 | 47 | \snippet qmlpolarchart/qml/qmlpolarchart/View1.qml 1 |
|
46 | 48 | |
|
47 | 49 | \beginfloatleft |
|
48 | 50 | \image examples_qmlpolarchart1.png |
|
49 | 51 | \endfloat |
|
50 | 52 | \clearfloat |
|
51 | 53 | */ |
|
52 | 54 | |
|
53 | 55 | DeclarativePolarChart::DeclarativePolarChart(QQuickItem *parent) |
|
54 | 56 | : DeclarativeChart(QChart::ChartTypePolar, parent) |
|
55 | 57 | { |
|
56 | 58 | } |
|
57 | 59 | |
|
58 | 60 | DeclarativePolarChart::~DeclarativePolarChart() |
|
59 | 61 | { |
|
60 | 62 | } |
|
61 | 63 | |
|
62 | 64 | #include "moc_declarativepolarchart.cpp" |
|
63 | 65 | |
|
64 | 66 | QT_CHARTS_END_NAMESPACE |
@@ -1,54 +1,56 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2014 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativexypoint.h" |
|
22 | 22 | #include <QtCore/QDataStream> |
|
23 | 23 | |
|
24 | 24 | QT_CHARTS_BEGIN_NAMESPACE |
|
25 | 25 | |
|
26 | 26 | /*! |
|
27 | 27 | \qmltype XYPoint |
|
28 | 28 | \inqmlmodule QtCharts |
|
29 | 29 | |
|
30 | \brief Type is used to initialize XY-series coordinate data. | |
|
31 | ||
|
30 | 32 | XYPoint is a convenience element for initializing XY-series with static coordinate data. To |
|
31 | 33 | manipulate an XY-series dynamically, use it's data manipulation functions instead. |
|
32 | 34 | \sa LineSeries, AreaSeries, ScatterSeries, SplineSeries |
|
33 | 35 | */ |
|
34 | 36 | |
|
35 | 37 | /*! |
|
36 | 38 | \qmlproperty real XYPoint::x |
|
37 | 39 | The x-coordinate of the point. |
|
38 | 40 | */ |
|
39 | 41 | |
|
40 | 42 | /*! |
|
41 | 43 | \qmlproperty real XYPoint::y |
|
42 | 44 | The y-coordinate of the point. |
|
43 | 45 | */ |
|
44 | 46 | |
|
45 | 47 | DeclarativeXYPoint::DeclarativeXYPoint(QObject *parent) : |
|
46 | 48 | QObject(parent) |
|
47 | 49 | { |
|
48 | 50 | setX(0.0); |
|
49 | 51 | setY(0.0); |
|
50 | 52 | } |
|
51 | 53 | |
|
52 | 54 | #include "moc_declarativexypoint.cpp" |
|
53 | 55 | |
|
54 | 56 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now