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