##// END OF EJS Templates
QML PieSlice documentation
Tero Ahola -
r1470:048f828e9404
parent child
Show More
@@ -1,74 +1,76
1 /*!
1 /*!
2 \page qml.html
2 \page qml.html
3 \title QtCommercial Charts QML API
3 \title QtCommercial Charts QML API
4 \keyword Charts QML API
4 \keyword Charts QML API
5
5
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
6 QtCommercial Charts QML API is an intuitive and simple way to show charts in your QML
7 applications. The following example QML shows you how to create a simple pie chart:
7 applications. The following example QML shows you how to create a simple pie chart:
8 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
8 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 1
9 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
10 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 3
9
11
10 \beginfloatleft
12 \beginfloatleft
11 \image examples_qmlpiechart.png
13 \image examples_qmlpiechart.png
12 \endfloat
14 \endfloat
13 \clearfloat
15 \clearfloat
14
16
15 \raw HTML
17 \raw HTML
16 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
18 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
17 <tr>
19 <tr>
18 <th class="titleheader" width="25%"> ChartView and it's properties </th>
20 <th class="titleheader" width="25%"> ChartView and it's properties </th>
19 </tr>
21 </tr>
20 <tr>
22 <tr>
21 <td valign="top">
23 <td valign="top">
22 <ul>
24 <ul>
23 <li><a href="qml-chartview.html">ChartView</a></li>
25 <li><a href="qml-chartview.html">ChartView</a></li>
24 <li><a href="qml-axis.html">Axis</a></li>
26 <li><a href="qml-axis.html">Axis</a></li>
25 <li><a href="qml-legend.html">Legend</a></li>
27 <li><a href="qml-legend.html">Legend</a></li>
26 </ul>
28 </ul>
27 </td>
29 </td>
28 </tr>
30 </tr>
29 </table>
31 </table>
30 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
32 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
31 <tr>
33 <tr>
32 <th class="titleheader" width="25%"> XY chart </th>
34 <th class="titleheader" width="25%"> XY chart </th>
33 </tr>
35 </tr>
34 <tr>
36 <tr>
35 <td valign="top">
37 <td valign="top">
36 <ul>
38 <ul>
37 <li><a href="qml-lineseries.html">LineSeries</a></li>
39 <li><a href="qml-lineseries.html">LineSeries</a></li>
38 <li><a href="qml-areaseries.html">AreaSeries</a></li>
40 <li><a href="qml-areaseries.html">AreaSeries</a></li>
39 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
41 <li><a href="qml-scatterseries.html">ScatterSeries</a></li>
40 <li><a href="qml-splineseries.html">SplineSeries</a></li>
42 <li><a href="qml-splineseries.html">SplineSeries</a></li>
41 <li><a href="qml-xypoint.html">XyPoint</a></li>
43 <li><a href="qml-xypoint.html">XyPoint</a></li>
42 </ul>
44 </ul>
43 </td>
45 </td>
44 </tr>
46 </tr>
45 </table>
47 </table>
46 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
48 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
47 <tr>
49 <tr>
48 <th class="titleheader" width="25%"> Pie chart </th>
50 <th class="titleheader" width="25%"> Pie chart </th>
49 <tr>
51 <tr>
50 <td valign="top">
52 <td valign="top">
51 <ul>
53 <ul>
52 <li><a href="qml-pieseries.html">PieSeries</a></li>
54 <li><a href="qml-pieseries.html">PieSeries</a></li>
53 <li><a href="qml-pieslice.html">PieSlice</a></li>
55 <li><a href="qml-pieslice.html">PieSlice</a></li>
54 </ul>
56 </ul>
55 </td>
57 </td>
56 </tr>
58 </tr>
57 </table>
59 </table>
58 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
60 <table cellpadding="2" cellspacing="1" border="0" width="95%" class="indextable">
59 <tr>
61 <tr>
60 <th class="titleheader" width="25%"> Bar chart </th>
62 <th class="titleheader" width="25%"> Bar chart </th>
61 <tr>
63 <tr>
62 <td valign="top">
64 <td valign="top">
63 <ul>
65 <ul>
64 <li><a href="qml-barseries.html">BarSeries</a></li>
66 <li><a href="qml-barseries.html">BarSeries</a></li>
65 <li><a href="qml-groupedbarseries.html">GroupedBarSeries</a></li>
67 <li><a href="qml-groupedbarseries.html">GroupedBarSeries</a></li>
66 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
68 <li><a href="qml-stackedbarseries.html">StackedBarSeries</a></li>
67 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
69 <li><a href="qml-percentbarseries.html">PercentBarSeries</a></li>
68 <li><a href="qml-barset.html">BarSet</a></li>
70 <li><a href="qml-barset.html">BarSet</a></li>
69 </ul>
71 </ul>
70 </td>
72 </td>
71 </tr>
73 </tr>
72 </table>
74 </table>
73 \endraw
75 \endraw
74 */
76 */
@@ -1,734 +1,813
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qpieslice.h"
21 #include "qpieslice.h"
22 #include "qpieslice_p.h"
22 #include "qpieslice_p.h"
23
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
25
26 /*!
26 /*!
27 \class QPieSlice
27 \class QPieSlice
28 \brief Defines a slice in pie series.
28 \brief Defines a slice in pie series.
29
29
30 This object defines the properties of a single slice in a QPieSeries.
30 This object defines the properties of a single slice in a QPieSeries.
31
31
32 In addition to the obvious value and label properties the user can also control
32 In addition to the obvious value and label properties the user can also control
33 the visual appearance of a slice. By modifying the visual appearance also means that
33 the visual appearance of a slice. By modifying the visual appearance also means that
34 the user is overriding the default appearance set by the theme.
34 the user is overriding the default appearance set by the theme.
35
35
36 Note that if the user has customized slices and theme is changed all customizations will be lost.
36 Note that if the user has customized slices and theme is changed all customizations will be lost.
37
37
38 To enable user interaction with the pie some basic signals are provided about clicking and hovering.
38 To enable user interaction with the pie some basic signals are provided about clicking and hovering.
39 */
39 */
40
40
41 /*!
41 /*!
42 \qmlclass PieSlice QPieSlice
43 PieSlice defines the properties of a single slice in a PieSeries. The element should be used
44 as a child for a PieSeries. For example:
45 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 2
46
47 An alternative (dynamic) method for adding slices to a PieSeries is using PieSeries.append
48 method.
49 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 4
50
51 In that case you may want to use PieSeries.at or PieSeries.find to access the properties of
52 an individual PieSlice instance.
53 \snippet ../examples/qmlpiechart/qml/qmlpiechart/main.qml 5
54 \sa PieSeries
55 */
56
57 /*!
42 \enum QPieSlice::LabelPosition
58 \enum QPieSlice::LabelPosition
43
59
44 This enum describes the position of the slice label.
60 This enum describes the position of the slice label.
45
61
46 \value LabelOutside Label is outside the slice with an arm.
62 \value LabelOutside Label is outside the slice with an arm.
47 \value LabelInside Label is centered inside the slice.
63 \value LabelInside Label is centered inside the slice.
48
64
49 */
65 */
50
66
51 /*!
67 /*!
52 \property QPieSlice::label
68 \property QPieSlice::label
53
54 Label of the slice.
69 Label of the slice.
55
56 \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor
70 \sa labelVisible, labelBrush, labelFont, labelArmLengthFactor
57 */
71 */
72 /*!
73 \qmlproperty string PieSlice::label
74 Label (text) of the slice.
75 */
58
76
59 /*!
77 /*!
60 \fn void QPieSlice::labelChanged()
78 \fn void QPieSlice::labelChanged()
61
62 This signal emitted when the slice label has been changed.
79 This signal emitted when the slice label has been changed.
63
80 \sa label
81 */
82 /*!
83 \qmlsignal PieSlice::labelChanged()
84 This signal emitted when the slice label has been changed.
64 \sa label
85 \sa label
65 */
86 */
66
87
67 /*!
88 /*!
68 \property QPieSlice::value
89 \property QPieSlice::value
69
70 Value of the slice.
90 Value of the slice.
71
72 Note that if users sets a negative value it is converted to a positive value.
91 Note that if users sets a negative value it is converted to a positive value.
73
74 \sa percentage(), QPieSeries::sum()
92 \sa percentage(), QPieSeries::sum()
75 */
93 */
94 /*!
95 \qmlproperty real PieSlice::value
96 Value of the slice. Note that if users sets a negative value it is converted to a positive value.
97 */
76
98
77 /*!
99 /*!
78 \fn void QPieSlice::valueChanged()
100 \fn void QPieSlice::valueChanged()
79
80 This signal is emitted when the slice value changes.
101 This signal is emitted when the slice value changes.
81
102 \sa value
103 */
104 /*!
105 \qmlsignal PieSlice::valueChanged()
106 This signal is emitted when the slice value changes.
82 \sa value
107 \sa value
83 */
108 */
84
109
85 /*!
110 /*!
86 \property QPieSlice::labelVisible
111 \property QPieSlice::labelVisible
87
112 Defines the visibility of slice label. By default the label is not visible.
88 Defienes the visibility of the slice label.
89
90 Default is not visible.
91
92 \sa label, labelBrush, labelFont, labelArmLengthFactor
113 \sa label, labelBrush, labelFont, labelArmLengthFactor
93 */
114 */
115 /*!
116 \qmlproperty bool PieSlice::labelVisible
117 Defines the visibility of slice label. By default the label is not visible.
118 */
94
119
95 /*!
120 /*!
96 \fn void QPieSlice::labelVisibleChanged()
121 \fn void QPieSlice::labelVisibleChanged()
97
98 This signal emitted when visibility of the slice label has changed.
122 This signal emitted when visibility of the slice label has changed.
99
123 \sa labelVisible
124 */
125 /*!
126 \qmlsignal PieSlice::labelVisibleChanged()
127 This signal emitted when visibility of the slice label has changed.
100 \sa labelVisible
128 \sa labelVisible
101 */
129 */
102
130
103 /*!
131 /*!
104 \property QPieSlice::exploded
132 \property QPieSlice::exploded
105
133 If set to true the slice is "exploded" away from the pie.
106 Defines if the slice is exploded from the pie.
134 \sa explodeDistanceFactor
107
135 */
136 /*!
137 \qmlproperty bool PieSlice::exploded
138 If set to true the slice is "exploded" away from the pie.
108 \sa explodeDistanceFactor
139 \sa explodeDistanceFactor
109 */
140 */
110
141
111 /*!
142 /*!
112 \fn void QPieSlice::explodedChanged()
143 \fn void QPieSlice::explodedChanged()
113
114 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
144 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
115
145 \sa exploded
146 */
147 /*!
148 \qmlsignal PieSlice::explodedChanged()
149 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
116 \sa exploded
150 \sa exploded
117 */
151 */
118
152
119 /*!
153 /*!
120 \property QPieSlice::pen
154 \property QPieSlice::pen
121
122 Pen used to draw the slice border.
155 Pen used to draw the slice border.
123 */
156 */
124
157
125 /*!
158 /*!
126 \fn void QPieSlice::penChanged()
159 \fn void QPieSlice::penChanged()
127
128 This signal is emitted when the pen of the slice has changed.
160 This signal is emitted when the pen of the slice has changed.
129
130 \sa pen
161 \sa pen
131 */
162 */
132
163
133 /*!
164 /*!
134 \property QPieSlice::borderColor
165 \property QPieSlice::borderColor
135
136 Color used to draw the slice border.
166 Color used to draw the slice border.
137
138 This is a convenience property for modifying the slice pen.
167 This is a convenience property for modifying the slice pen.
139
140 \sa pen, borderWidth
168 \sa pen, borderWidth
141 */
169 */
170 /*!
171 \qmlproperty color PieSlice::borderColor
172 Color used to draw the slice border (pen color).
173 \sa borderWidth
174 */
142
175
143 /*!
176 /*!
144 \fn void QPieSlice::borderColorChanged()
177 \fn void QPieSlice::borderColorChanged()
145
146 This signal is emitted when slice border color changes.
178 This signal is emitted when slice border color changes.
147
148 \sa pen, borderColor
179 \sa pen, borderColor
149 */
180 */
181 /*!
182 \qmlsignal PieSlice::borderColorChanged()
183 This signal is emitted when slice border color changes.
184 \sa borderColor
185 */
150
186
151 /*!
187 /*!
152 \property QPieSlice::borderWidth
188 \property QPieSlice::borderWidth
153
154 Width of the slice border.
189 Width of the slice border.
155
156 This is a convenience property for modifying the slice pen.
190 This is a convenience property for modifying the slice pen.
157
158 \sa pen, borderColor
191 \sa pen, borderColor
159 */
192 */
193 /*!
194 \qmlproperty int PieSlice::borderWidth
195 Width of the slice border.
196 This is a convenience property for modifying the slice pen.
197 \sa borderColor
198 */
160
199
161 /*!
200 /*!
162 \fn void QPieSlice::borderWidthChanged()
201 \fn void QPieSlice::borderWidthChanged()
163
164 This signal is emitted when slice border width changes.
202 This signal is emitted when slice border width changes.
165
166 \sa pen, borderWidth
203 \sa pen, borderWidth
167 */
204 */
205 /*!
206 \qmlsignal PieSlice::borderWidthChanged()
207 This signal is emitted when slice border width changes.
208 \sa borderWidth
209 */
168
210
169 /*!
211 /*!
170 \property QPieSlice::brush
212 \property QPieSlice::brush
171
172 Brush used to draw the slice.
213 Brush used to draw the slice.
173 */
214 */
174
215
175 /*!
216 /*!
176 \fn void QPieSlice::brushChanged()
217 \fn void QPieSlice::brushChanged()
177
178 This signal is emitted when the brush of the slice has changed.
218 This signal is emitted when the brush of the slice has changed.
179
180 \sa brush
219 \sa brush
181 */
220 */
182
221
183 /*!
222 /*!
184 \property QPieSlice::color
223 \property QPieSlice::color
185
224 Fill (brush) color of the slice.
186 Color used to draw the slice.
187
188 This is a convenience property for modifying the slice brush.
225 This is a convenience property for modifying the slice brush.
189
190 \sa brush
226 \sa brush
191 */
227 */
228 /*!
229 \qmlproperty color PieSlice::color
230 Fill (brush) color of the slice.
231 */
192
232
193 /*!
233 /*!
194 \fn void QPieSlice::colorChanged()
234 \fn void QPieSlice::colorChanged()
195
196 This signal is emitted when slice color changes.
235 This signal is emitted when slice color changes.
197
198 \sa brush
236 \sa brush
199 */
237 */
238 /*!
239 \qmlsignal PieSlice::colorChanged()
240 This signal is emitted when slice color changes.
241 */
200
242
201 /*!
243 /*!
202 \property QPieSlice::labelBrush
244 \property QPieSlice::labelBrush
203
245 Brush used to draw label and label arm of the slice.
204 Pen used to draw label and label arm of the slice.
205
206 \sa label, labelVisible, labelFont, labelArmLengthFactor
246 \sa label, labelVisible, labelFont, labelArmLengthFactor
207 */
247 */
208
248
209 /*!
249 /*!
210 \fn void QPieSlice::labelBrushChanged()
250 \fn void QPieSlice::labelBrushChanged()
211
212 This signal is emitted when the label pen of the slice has changed.
251 This signal is emitted when the label pen of the slice has changed.
213
214 \sa labelBrush
252 \sa labelBrush
215 */
253 */
216
254
217 /*!
255 /*!
218 \property QPieSlice::labelColor
256 \property QPieSlice::labelColor
219
220 Color used to draw the slice label.
257 Color used to draw the slice label.
221
222 This is a convenience property for modifying the slice label brush.
258 This is a convenience property for modifying the slice label brush.
223
224 \sa labelBrush
259 \sa labelBrush
225 */
260 */
261 /*!
262 \qmlproperty color PieSlice::labelColor
263 Color used to draw the slice label.
264 */
226
265
227 /*!
266 /*!
228 \fn void QPieSlice::labelColorChanged()
267 \fn void QPieSlice::labelColorChanged()
229
230 This signal is emitted when slice label color changes.
268 This signal is emitted when slice label color changes.
231
269 \sa labelColor
270 */
271 /*!
272 \qmlsignal PieSlice::labelColorChanged()
273 This signal is emitted when slice label color changes.
232 \sa labelColor
274 \sa labelColor
233 */
275 */
234
276
235 /*!
277 /*!
236 \property QPieSlice::labelFont
278 \property QPieSlice::labelFont
237
238 Font used for drawing label text.
279 Font used for drawing label text.
239
240 \sa label, labelVisible, labelArmLengthFactor
280 \sa label, labelVisible, labelArmLengthFactor
241 */
281 */
242
282
243 /*!
283 /*!
244 \fn void QPieSlice::labelFontChanged()
284 \fn void QPieSlice::labelFontChanged()
245
246 This signal is emitted when the label font of the slice has changed.
285 This signal is emitted when the label font of the slice has changed.
247
248 \sa labelFont
286 \sa labelFont
249 */
287 */
250
288
251 /*!
289 /*!
252 \property QPieSlice::labelPosition
290 \property QPieSlice::labelPosition
253
254 Position of the slice label.
291 Position of the slice label.
255
256 \sa label, labelVisible
292 \sa label, labelVisible
257 */
293 */
294 /*!
295 \qmlproperty LabelPosition PieSlice::labelPosition
296 Position of the slice label. One of PieSlice.LabelOutside or PieSlice.LabelInside.
297 \sa labelVisible
298 */
258
299
259 /*!
300 /*!
260 \fn void QPieSlice::labelPositionChanged()
301 \fn void QPieSlice::labelPositionChanged()
261
262 This signal is emitted when the label position of the slice has changed.
302 This signal is emitted when the label position of the slice has changed.
263
303 \sa labelPosition
304 */
305 /*!
306 \qmlsignal PieSlice::labelPositionChanged()
307 This signal is emitted when the label position of the slice has changed.
264 \sa labelPosition
308 \sa labelPosition
265 */
309 */
266
310
267 /*!
311 /*!
268 \property QPieSlice::labelArmLengthFactor
312 \property QPieSlice::labelArmLengthFactor
269
270 Defines the length of the label arm.
313 Defines the length of the label arm.
271
272 The factor is relative to pie radius. For example:
314 The factor is relative to pie radius. For example:
273 1.0 means the length is the same as the radius.
315 1.0 means the length is the same as the radius.
274 0.5 means the length is half of the radius.
316 0.5 means the length is half of the radius.
275
317 By default the arm length is 0.15
276 Default value is 0.15
277
278 \sa label, labelVisible, labelBrush, labelFont
318 \sa label, labelVisible, labelBrush, labelFont
279 */
319 */
320 /*!
321 \qmlproperty real PieSlice::labelArmLengthFactor
322 Defines the length of the label arm.
323 The factor is relative to pie radius. For example:
324 1.0 means the length is the same as the radius.
325 0.5 means the length is half of the radius.
326 By default the arm length is 0.15
327 \sa labelVisible
328 */
280
329
281 /*!
330 /*!
282 \fn void QPieSlice::labelArmLengthFactorChanged()
331 \fn void QPieSlice::labelArmLengthFactorChanged()
283
284 This signal is emitted when the label arm factor of the slice has changed.
332 This signal is emitted when the label arm factor of the slice has changed.
285
333 \sa labelArmLengthFactor
334 */
335 /*!
336 \qmlsignal PieSlice::labelArmLengthFactorChanged()
337 This signal is emitted when the label arm factor of the slice has changed.
286 \sa labelArmLengthFactor
338 \sa labelArmLengthFactor
287 */
339 */
288
340
289 /*!
341 /*!
290 \property QPieSlice::explodeDistanceFactor
342 \property QPieSlice::explodeDistanceFactor
291
292 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
343 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
293
294 The factor is relative to pie radius. For example:
344 The factor is relative to pie radius. For example:
295 1.0 means the distance is the same as the radius.
345 1.0 means the distance is the same as the radius.
296 0.5 means the distance is half of the radius.
346 0.5 means the distance is half of the radius.
297
347 By default the distance is is 0.15
298 Default value is 0.15
348 \sa exploded
299
349 */
350 /*!
351 \qmlproperty real PieSlice::explodeDistanceFactor
352 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
353 The factor is relative to pie radius. For example:
354 1.0 means the distance is the same as the radius.
355 0.5 means the distance is half of the radius.
356 By default the distance is is 0.15
300 \sa exploded
357 \sa exploded
301 */
358 */
302
359
303 /*!
360 /*!
304 \fn void QPieSlice::explodeDistanceFactorChanged()
361 \fn void QPieSlice::explodeDistanceFactorChanged()
305
306 This signal is emitted when the explode distance factor of the slice has changed.
362 This signal is emitted when the explode distance factor of the slice has changed.
307
363 \sa explodeDistanceFactor
364 */
365 /*!
366 \qmlsignal PieSlice::explodeDistanceFactorChanged()
367 This signal is emitted when the explode distance factor of the slice has changed.
308 \sa explodeDistanceFactor
368 \sa explodeDistanceFactor
309 */
369 */
310
370
311 /*!
371 /*!
312 \property QPieSlice::percentage
372 \property QPieSlice::percentage
313
314 Percentage of the slice compared to the sum of all slices in the series.
373 Percentage of the slice compared to the sum of all slices in the series.
315
316 The actual value ranges from 0.0 to 1.0.
374 The actual value ranges from 0.0 to 1.0.
317
318 Updated automatically once the slice is added to the series.
375 Updated automatically once the slice is added to the series.
319
320 \sa value, QPieSeries::sum
376 \sa value, QPieSeries::sum
321 */
377 */
378 /*!
379 \qmlproperty real PieSlice::percentage
380 Percentage of the slice compared to the sum of all slices in the series.
381 The actual value ranges from 0.0 to 1.0.
382 Updated automatically once the slice is added to the series.
383 */
322
384
323 /*!
385 /*!
324 \fn void QPieSlice::percentageChanged()
386 \fn void QPieSlice::percentageChanged()
325
326 This signal is emitted when the percentage of the slice has changed.
387 This signal is emitted when the percentage of the slice has changed.
327
388 \sa percentage
389 */
390 /*!
391 \qmlsignal void PieSlice::percentageChanged()
392 This signal is emitted when the percentage of the slice has changed.
328 \sa percentage
393 \sa percentage
329 */
394 */
330
395
331 /*!
396 /*!
332 \property QPieSlice::startAngle
397 \property QPieSlice::startAngle
333
334 Defines the starting angle of this slice in the series it belongs to.
398 Defines the starting angle of this slice in the series it belongs to.
335
336 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
399 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
337
400 Updated automatically once the slice is added to the series.
401 */
402 /*!
403 \qmlproperty real PieSlice::startAngle
404 Defines the starting angle of this slice in the series it belongs to.
405 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
338 Updated automatically once the slice is added to the series.
406 Updated automatically once the slice is added to the series.
339 */
407 */
340
408
341 /*!
409 /*!
342 \fn void QPieSlice::startAngleChanged()
410 \fn void QPieSlice::startAngleChanged()
343
344 This signal is emitted when the starting angle f the slice has changed.
411 This signal is emitted when the starting angle f the slice has changed.
345
412 \sa startAngle
413 */
414 /*!
415 \qmlsignal PieSlice::startAngleChanged()
416 This signal is emitted when the starting angle f the slice has changed.
346 \sa startAngle
417 \sa startAngle
347 */
418 */
348
419
349 /*!
420 /*!
350 \property QPieSlice::angleSpan
421 \property QPieSlice::angleSpan
351
352 Span of the slice in degrees.
422 Span of the slice in degrees.
353
354 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
423 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
355
424 Updated automatically once the slice is added to the series.
425 */
426 /*!
427 \qmlproperty real PieSlice::angleSpan
428 Span of the slice in degrees.
429 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
356 Updated automatically once the slice is added to the series.
430 Updated automatically once the slice is added to the series.
357 */
431 */
358
432
359 /*!
433 /*!
360 \fn void QPieSlice::angleSpanChanged()
434 \fn void QPieSlice::angleSpanChanged()
361
362 This signal is emitted when the angle span of the slice has changed.
435 This signal is emitted when the angle span of the slice has changed.
363
364 \sa angleSpan
436 \sa angleSpan
365 */
437 */
366
438 /*!
439 \qmlsignal PieSlice::angleSpanChanged()
440 This signal is emitted when the angle span of the slice has changed.
441 \sa angleSpan
442 */
367
443
368 /*!
444 /*!
369 \fn void QPieSlice::clicked()
445 \fn void QPieSlice::clicked()
370
371 This signal is emitted when user has clicked the slice.
446 This signal is emitted when user has clicked the slice.
372
373 \sa QPieSeries::clicked()
447 \sa QPieSeries::clicked()
374 */
448 */
449 /*!
450 \qmlsignal PieSlice::onClicked()
451 This signal is emitted when user has clicked the slice.
452 */
375
453
376 /*!
454 /*!
377 \fn void QPieSlice::hovered(bool state)
455 \fn void QPieSlice::hovered(bool state)
378
379 This signal is emitted when user has hovered over or away from the slice.
456 This signal is emitted when user has hovered over or away from the slice.
380
381 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
457 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
382
383 \sa QPieSeries::hovered()
458 \sa QPieSeries::hovered()
384 */
459 */
460 /*!
461 \qmlsignal PieSlice::onHovered(bool state)
462 This signal is emitted when user has hovered over or away from the slice.
463 \a state is true when user has hovered over the slice and false when hover has moved away from the slice.
464 */
385
465
386 /*!
466 /*!
387 Constructs an empty slice with a \a parent.
467 Constructs an empty slice with a \a parent.
388
389 \sa QPieSeries::append(), QPieSeries::insert()
468 \sa QPieSeries::append(), QPieSeries::insert()
390 */
469 */
391 QPieSlice::QPieSlice(QObject *parent)
470 QPieSlice::QPieSlice(QObject *parent)
392 :QObject(parent),
471 :QObject(parent),
393 d_ptr(new QPieSlicePrivate(this))
472 d_ptr(new QPieSlicePrivate(this))
394 {
473 {
395
474
396 }
475 }
397
476
398 /*!
477 /*!
399 Constructs an empty slice with given \a value, \a label and a \a parent.
478 Constructs an empty slice with given \a value, \a label and a \a parent.
400 \sa QPieSeries::append(), QPieSeries::insert()
479 \sa QPieSeries::append(), QPieSeries::insert()
401 */
480 */
402 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
481 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
403 :QObject(parent),
482 :QObject(parent),
404 d_ptr(new QPieSlicePrivate(this))
483 d_ptr(new QPieSlicePrivate(this))
405 {
484 {
406 setValue(value);
485 setValue(value);
407 setLabel(label);
486 setLabel(label);
408 }
487 }
409
488
410 /*!
489 /*!
411 Destroys the slice.
490 Destroys the slice.
412 User should not delete the slice if it has been added to the series.
491 User should not delete the slice if it has been added to the series.
413 */
492 */
414 QPieSlice::~QPieSlice()
493 QPieSlice::~QPieSlice()
415 {
494 {
416
495
417 }
496 }
418
497
419 void QPieSlice::setLabel(QString label)
498 void QPieSlice::setLabel(QString label)
420 {
499 {
421 if (d_ptr->m_data.m_labelText != label) {
500 if (d_ptr->m_data.m_labelText != label) {
422 d_ptr->m_data.m_labelText = label;
501 d_ptr->m_data.m_labelText = label;
423 emit labelChanged();
502 emit labelChanged();
424 }
503 }
425 }
504 }
426
505
427 QString QPieSlice::label() const
506 QString QPieSlice::label() const
428 {
507 {
429 return d_ptr->m_data.m_labelText;
508 return d_ptr->m_data.m_labelText;
430 }
509 }
431
510
432 void QPieSlice::setValue(qreal value)
511 void QPieSlice::setValue(qreal value)
433 {
512 {
434 value = qAbs(value); // negative values not allowed
513 value = qAbs(value); // negative values not allowed
435 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
514 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
436 d_ptr->m_data.m_value = value;
515 d_ptr->m_data.m_value = value;
437 emit valueChanged();
516 emit valueChanged();
438 }
517 }
439 }
518 }
440
519
441 qreal QPieSlice::value() const
520 qreal QPieSlice::value() const
442 {
521 {
443 return d_ptr->m_data.m_value;
522 return d_ptr->m_data.m_value;
444 }
523 }
445
524
446 void QPieSlice::setLabelVisible(bool visible)
525 void QPieSlice::setLabelVisible(bool visible)
447 {
526 {
448 if (d_ptr->m_data.m_isLabelVisible != visible) {
527 if (d_ptr->m_data.m_isLabelVisible != visible) {
449 d_ptr->m_data.m_isLabelVisible = visible;
528 d_ptr->m_data.m_isLabelVisible = visible;
450 emit labelVisibleChanged();
529 emit labelVisibleChanged();
451 }
530 }
452 }
531 }
453
532
454 bool QPieSlice::isLabelVisible() const
533 bool QPieSlice::isLabelVisible() const
455 {
534 {
456 return d_ptr->m_data.m_isLabelVisible;
535 return d_ptr->m_data.m_isLabelVisible;
457 }
536 }
458
537
459 void QPieSlice::setExploded(bool exploded)
538 void QPieSlice::setExploded(bool exploded)
460 {
539 {
461 if (d_ptr->m_data.m_isExploded != exploded) {
540 if (d_ptr->m_data.m_isExploded != exploded) {
462 d_ptr->m_data.m_isExploded = exploded;
541 d_ptr->m_data.m_isExploded = exploded;
463 emit explodedChanged();
542 emit explodedChanged();
464 }
543 }
465 }
544 }
466
545
467 QPieSlice::LabelPosition QPieSlice::labelPosition()
546 QPieSlice::LabelPosition QPieSlice::labelPosition()
468 {
547 {
469 return d_ptr->m_data.m_labelPosition;
548 return d_ptr->m_data.m_labelPosition;
470 }
549 }
471
550
472 void QPieSlice::setLabelPosition(LabelPosition position)
551 void QPieSlice::setLabelPosition(LabelPosition position)
473 {
552 {
474 if (d_ptr->m_data.m_labelPosition != position) {
553 if (d_ptr->m_data.m_labelPosition != position) {
475 d_ptr->m_data.m_labelPosition = position;
554 d_ptr->m_data.m_labelPosition = position;
476 emit labelPositionChanged();
555 emit labelPositionChanged();
477 }
556 }
478 }
557 }
479
558
480 bool QPieSlice::isExploded() const
559 bool QPieSlice::isExploded() const
481 {
560 {
482 return d_ptr->m_data.m_isExploded;
561 return d_ptr->m_data.m_isExploded;
483 }
562 }
484
563
485 void QPieSlice::setPen(const QPen &pen)
564 void QPieSlice::setPen(const QPen &pen)
486 {
565 {
487 d_ptr->setPen(pen, false);
566 d_ptr->setPen(pen, false);
488 }
567 }
489
568
490 QPen QPieSlice::pen() const
569 QPen QPieSlice::pen() const
491 {
570 {
492 return d_ptr->m_data.m_slicePen;
571 return d_ptr->m_data.m_slicePen;
493 }
572 }
494
573
495 QColor QPieSlice::borderColor()
574 QColor QPieSlice::borderColor()
496 {
575 {
497 return pen().color();
576 return pen().color();
498 }
577 }
499
578
500 void QPieSlice::setBorderColor(QColor color)
579 void QPieSlice::setBorderColor(QColor color)
501 {
580 {
502 QPen p = pen();
581 QPen p = pen();
503 if (color != p.color()) {
582 if (color != p.color()) {
504 p.setColor(color);
583 p.setColor(color);
505 setPen(p);
584 setPen(p);
506 }
585 }
507 }
586 }
508
587
509 int QPieSlice::borderWidth()
588 int QPieSlice::borderWidth()
510 {
589 {
511 return pen().width();
590 return pen().width();
512 }
591 }
513
592
514 void QPieSlice::setBorderWidth(int width)
593 void QPieSlice::setBorderWidth(int width)
515 {
594 {
516 QPen p = pen();
595 QPen p = pen();
517 if (width != p.width()) {
596 if (width != p.width()) {
518 p.setWidth(width);
597 p.setWidth(width);
519 setPen(p);
598 setPen(p);
520 }
599 }
521 }
600 }
522
601
523 void QPieSlice::setBrush(const QBrush &brush)
602 void QPieSlice::setBrush(const QBrush &brush)
524 {
603 {
525 d_ptr->setBrush(brush, false);
604 d_ptr->setBrush(brush, false);
526 }
605 }
527
606
528 QBrush QPieSlice::brush() const
607 QBrush QPieSlice::brush() const
529 {
608 {
530 return d_ptr->m_data.m_sliceBrush;
609 return d_ptr->m_data.m_sliceBrush;
531 }
610 }
532
611
533 QColor QPieSlice::color()
612 QColor QPieSlice::color()
534 {
613 {
535 return brush().color();
614 return brush().color();
536 }
615 }
537
616
538 void QPieSlice::setColor(QColor color)
617 void QPieSlice::setColor(QColor color)
539 {
618 {
540 QBrush b = brush();
619 QBrush b = brush();
541 if (color != b.color()) {
620 if (color != b.color()) {
542 b.setColor(color);
621 b.setColor(color);
543 setBrush(b);
622 setBrush(b);
544 }
623 }
545 }
624 }
546
625
547 void QPieSlice::setLabelBrush(const QBrush &brush)
626 void QPieSlice::setLabelBrush(const QBrush &brush)
548 {
627 {
549 d_ptr->setLabelBrush(brush, false);
628 d_ptr->setLabelBrush(brush, false);
550 }
629 }
551
630
552 QBrush QPieSlice::labelBrush() const
631 QBrush QPieSlice::labelBrush() const
553 {
632 {
554 return d_ptr->m_data.m_labelBrush;
633 return d_ptr->m_data.m_labelBrush;
555 }
634 }
556
635
557 QColor QPieSlice::labelColor()
636 QColor QPieSlice::labelColor()
558 {
637 {
559 return labelBrush().color();
638 return labelBrush().color();
560 }
639 }
561
640
562 void QPieSlice::setLabelColor(QColor color)
641 void QPieSlice::setLabelColor(QColor color)
563 {
642 {
564 QBrush b = labelBrush();
643 QBrush b = labelBrush();
565 if (color != b.color()) {
644 if (color != b.color()) {
566 b.setColor(color);
645 b.setColor(color);
567 setLabelBrush(b);
646 setLabelBrush(b);
568 }
647 }
569 }
648 }
570
649
571 void QPieSlice::setLabelFont(const QFont &font)
650 void QPieSlice::setLabelFont(const QFont &font)
572 {
651 {
573 d_ptr->setLabelFont(font, false);
652 d_ptr->setLabelFont(font, false);
574 }
653 }
575
654
576 QFont QPieSlice::labelFont() const
655 QFont QPieSlice::labelFont() const
577 {
656 {
578 return d_ptr->m_data.m_labelFont;
657 return d_ptr->m_data.m_labelFont;
579 }
658 }
580
659
581 void QPieSlice::setLabelArmLengthFactor(qreal factor)
660 void QPieSlice::setLabelArmLengthFactor(qreal factor)
582 {
661 {
583 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
662 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
584 d_ptr->m_data.m_labelArmLengthFactor = factor;
663 d_ptr->m_data.m_labelArmLengthFactor = factor;
585 emit labelArmLengthFactorChanged();
664 emit labelArmLengthFactorChanged();
586 }
665 }
587 }
666 }
588
667
589 qreal QPieSlice::labelArmLengthFactor() const
668 qreal QPieSlice::labelArmLengthFactor() const
590 {
669 {
591 return d_ptr->m_data.m_labelArmLengthFactor;
670 return d_ptr->m_data.m_labelArmLengthFactor;
592 }
671 }
593
672
594 void QPieSlice::setExplodeDistanceFactor(qreal factor)
673 void QPieSlice::setExplodeDistanceFactor(qreal factor)
595 {
674 {
596 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
675 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
597 d_ptr->m_data.m_explodeDistanceFactor = factor;
676 d_ptr->m_data.m_explodeDistanceFactor = factor;
598 emit explodeDistanceFactorChanged();
677 emit explodeDistanceFactorChanged();
599 }
678 }
600 }
679 }
601
680
602 qreal QPieSlice::explodeDistanceFactor() const
681 qreal QPieSlice::explodeDistanceFactor() const
603 {
682 {
604 return d_ptr->m_data.m_explodeDistanceFactor;
683 return d_ptr->m_data.m_explodeDistanceFactor;
605 }
684 }
606
685
607 qreal QPieSlice::percentage() const
686 qreal QPieSlice::percentage() const
608 {
687 {
609 return d_ptr->m_data.m_percentage;
688 return d_ptr->m_data.m_percentage;
610 }
689 }
611
690
612 qreal QPieSlice::startAngle() const
691 qreal QPieSlice::startAngle() const
613 {
692 {
614 return d_ptr->m_data.m_startAngle;
693 return d_ptr->m_data.m_startAngle;
615 }
694 }
616
695
617 qreal QPieSlice::angleSpan() const
696 qreal QPieSlice::angleSpan() const
618 {
697 {
619 return d_ptr->m_data.m_angleSpan;
698 return d_ptr->m_data.m_angleSpan;
620 }
699 }
621
700
622 /*!
701 /*!
623 Returns the series that this slice belongs to.
702 Returns the series that this slice belongs to.
624
703
625 \sa QPieSeries::append()
704 \sa QPieSeries::append()
626 */
705 */
627 QPieSeries *QPieSlice::series() const
706 QPieSeries *QPieSlice::series() const
628 {
707 {
629 return d_ptr->m_series;
708 return d_ptr->m_series;
630 }
709 }
631
710
632 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
711 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
633 :QObject(parent),
712 :QObject(parent),
634 q_ptr(parent),
713 q_ptr(parent),
635 m_series(0)
714 m_series(0)
636 {
715 {
637
716
638 }
717 }
639
718
640 QPieSlicePrivate::~QPieSlicePrivate()
719 QPieSlicePrivate::~QPieSlicePrivate()
641 {
720 {
642
721
643 }
722 }
644
723
645 QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice)
724 QPieSlicePrivate *QPieSlicePrivate::fromSlice(QPieSlice *slice)
646 {
725 {
647 return slice->d_func();
726 return slice->d_func();
648 }
727 }
649
728
650 void QPieSlicePrivate::setPen(const QPen &pen, bool themed)
729 void QPieSlicePrivate::setPen(const QPen &pen, bool themed)
651 {
730 {
652 if (m_data.m_slicePen != pen) {
731 if (m_data.m_slicePen != pen) {
653
732
654 QPen oldPen = m_data.m_slicePen;
733 QPen oldPen = m_data.m_slicePen;
655
734
656 m_data.m_slicePen = pen;
735 m_data.m_slicePen = pen;
657 m_data.m_slicePen.setThemed(themed);
736 m_data.m_slicePen.setThemed(themed);
658
737
659 emit q_ptr->penChanged();
738 emit q_ptr->penChanged();
660 if (oldPen.color() != pen.color())
739 if (oldPen.color() != pen.color())
661 emit q_ptr->borderColorChanged();
740 emit q_ptr->borderColorChanged();
662 if (oldPen.width() != pen.width())
741 if (oldPen.width() != pen.width())
663 emit q_ptr->borderWidthChanged();
742 emit q_ptr->borderWidthChanged();
664 }
743 }
665 }
744 }
666
745
667 void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed)
746 void QPieSlicePrivate::setBrush(const QBrush &brush, bool themed)
668 {
747 {
669 if (m_data.m_sliceBrush != brush) {
748 if (m_data.m_sliceBrush != brush) {
670
749
671 QBrush oldBrush = m_data.m_sliceBrush;
750 QBrush oldBrush = m_data.m_sliceBrush;
672
751
673 m_data.m_sliceBrush = brush;
752 m_data.m_sliceBrush = brush;
674 m_data.m_sliceBrush.setThemed(themed);
753 m_data.m_sliceBrush.setThemed(themed);
675
754
676 emit q_ptr->brushChanged();
755 emit q_ptr->brushChanged();
677 if (oldBrush.color() != brush.color())
756 if (oldBrush.color() != brush.color())
678 emit q_ptr->colorChanged();
757 emit q_ptr->colorChanged();
679 }
758 }
680 }
759 }
681
760
682 void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed)
761 void QPieSlicePrivate::setLabelBrush(const QBrush &brush, bool themed)
683 {
762 {
684 if (m_data.m_labelBrush != brush) {
763 if (m_data.m_labelBrush != brush) {
685
764
686 QBrush oldBrush = m_data.m_labelBrush;
765 QBrush oldBrush = m_data.m_labelBrush;
687
766
688 m_data.m_labelBrush = brush;
767 m_data.m_labelBrush = brush;
689 m_data.m_labelBrush.setThemed(themed);
768 m_data.m_labelBrush.setThemed(themed);
690
769
691 emit q_ptr->labelBrushChanged();
770 emit q_ptr->labelBrushChanged();
692 if (oldBrush.color() != brush.color())
771 if (oldBrush.color() != brush.color())
693 emit q_ptr->labelColorChanged();
772 emit q_ptr->labelColorChanged();
694 }
773 }
695 }
774 }
696
775
697 void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed)
776 void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed)
698 {
777 {
699 if (m_data.m_labelFont != font) {
778 if (m_data.m_labelFont != font) {
700 m_data.m_labelFont = font;
779 m_data.m_labelFont = font;
701 m_data.m_labelFont.setThemed(themed);
780 m_data.m_labelFont.setThemed(themed);
702 emit q_ptr->labelFontChanged();
781 emit q_ptr->labelFontChanged();
703 }
782 }
704 }
783 }
705
784
706 void QPieSlicePrivate::setPercentage(qreal percentage)
785 void QPieSlicePrivate::setPercentage(qreal percentage)
707 {
786 {
708 if (!qFuzzyIsNull(m_data.m_percentage - percentage)) {
787 if (!qFuzzyIsNull(m_data.m_percentage - percentage)) {
709 m_data.m_percentage = percentage;
788 m_data.m_percentage = percentage;
710 emit q_ptr->percentageChanged();
789 emit q_ptr->percentageChanged();
711 }
790 }
712 }
791 }
713
792
714 void QPieSlicePrivate::setStartAngle(qreal angle)
793 void QPieSlicePrivate::setStartAngle(qreal angle)
715 {
794 {
716 if (!qFuzzyIsNull(m_data.m_startAngle - angle)) {
795 if (!qFuzzyIsNull(m_data.m_startAngle - angle)) {
717 m_data.m_startAngle = angle;
796 m_data.m_startAngle = angle;
718 emit q_ptr->startAngleChanged();
797 emit q_ptr->startAngleChanged();
719 }
798 }
720 }
799 }
721
800
722 void QPieSlicePrivate::setAngleSpan(qreal span)
801 void QPieSlicePrivate::setAngleSpan(qreal span)
723 {
802 {
724 if (!qFuzzyIsNull(m_data.m_angleSpan - span)) {
803 if (!qFuzzyIsNull(m_data.m_angleSpan - span)) {
725 m_data.m_angleSpan = span;
804 m_data.m_angleSpan = span;
726 emit q_ptr->angleSpanChanged();
805 emit q_ptr->angleSpanChanged();
727 }
806 }
728 }
807 }
729
808
730 QTCOMMERCIALCHART_END_NAMESPACE
809 QTCOMMERCIALCHART_END_NAMESPACE
731
810
732 QTCOMMERCIALCHART_USE_NAMESPACE
811 QTCOMMERCIALCHART_USE_NAMESPACE
733 #include "moc_qpieslice.cpp"
812 #include "moc_qpieslice.cpp"
734 #include "moc_qpieslice_p.cpp"
813 #include "moc_qpieslice_p.cpp"
@@ -1,166 +1,168
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Flow {
24 Flow {
25 id: flow
25 id: flow
26 spacing: 5
26 spacing: 5
27 flow: Flow.TopToBottom
27 flow: Flow.TopToBottom
28 property variant series
28 property variant series
29
29
30 onSeriesChanged: {
30 onSeriesChanged: {
31 seriesConnections.target = series;
31 seriesConnections.target = series;
32 sliceConnections.target = series.at(0);
32 sliceConnections.target = series.at(0);
33 }
33 }
34
34
35 Connections {
35 Connections {
36 id: seriesConnections
36 id: seriesConnections
37 ignoreUnknownSignals: true
37 ignoreUnknownSignals: true
38 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
38 onVisibleChanged: console.log("series.onVisibleChanged: " + series.visible);
39 onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition);
39 onHorizontalPositionChanged:console.log("series.onHorizontalPositionChanged: " + series.horizontalPosition);
40 onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition);
40 onVerticalPositionChanged: console.log("series.onVerticalPositionChanged: " + series.verticalPosition);
41 onSizeChanged: console.log("series.onSizeChanged: " + series.size);
41 onSizeChanged: console.log("series.onSizeChanged: " + series.size);
42 onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle);
42 onStartAngleChanged: console.log("series.onStartAngleChanged: " + series.startAngle);
43 onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle);
43 onEndAngleChanged: console.log("series.onEndAngleChanged: " + series.endAngle);
44 onCountChanged: console.log("series.onCountChanged: " + series.count);
44 onCountChanged: console.log("series.onCountChanged: " + series.count);
45 onSumChanged: console.log("series.onSumChanged: " + series.sum);
45 onSumChanged: console.log("series.onSumChanged: " + series.sum);
46 }
46 }
47
47
48 Connections {
48 Connections {
49 id: sliceConnections
49 id: sliceConnections
50 ignoreUnknownSignals: true
50 ignoreUnknownSignals: true
51 onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
51 onValueChanged: console.log("slice.onValueChanged: " + series.at(0).value);
52 onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
52 onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + series.at(0).labelVisible);
53 onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition);
53 onLabelPositionChanged: console.log("slice.onLabelPositionChanged: " + series.at(0).labelPosition);
54 onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded);
54 onExplodedChanged: console.log("slice.onExplodedChanged: " + series.at(0).exploded);
55 onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
55 onPenChanged: console.log("slice.onPenChanged: " + series.at(0).pen);
56 onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
56 onBorderColorChanged: console.log("slice.onBorderColorChanged: " + series.at(0).borderColor);
57 onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
57 onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + series.at(0).borderWidth);
58 onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush);
58 onBrushChanged: console.log("slice.onBrushChanged: " + series.at(0).brush);
59 onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color);
59 onColorChanged: console.log("slice.onColorChanged: " + series.at(0).color);
60 onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
60 onLabelColorChanged: console.log("slice.onLabelColorChanged: " + series.at(0).labelColor);
61 onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
61 onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + series.at(0).labelBrush);
62 onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
62 onLabelFontChanged: console.log("slice.onLabelFontChanged: " + series.at(0).labelFont);
63 onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor);
63 onLabelArmLengthFactorChanged: console.log("slice.onLabelArmLengthFactorChanged: " + series.at(0).labelArmLengthFactor);
64 onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor);
64 onExplodeDistanceFactorChanged: console.log("slice.onExplodeDistanceFactorChanged: " + series.at(0).explodeDistanceFactor);
65 onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
65 onPercentageChanged: console.log("slice.onPercentageChanged: " + series.at(0).percentage);
66 onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
66 onStartAngleChanged: console.log("slice.onStartAngleChanged: " + series.at(0).startAngle);
67 onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);
67 onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + series.at(0).angleSpan);
68 onClicked: console.log("slice.onClicked");
69 onHovered: console.log("slice.onHovered: " + state);
68 }
70 }
69
71
70 Button {
72 Button {
71 text: "visible"
73 text: "visible"
72 onClicked: series.visible = !series.visible;
74 onClicked: series.visible = !series.visible;
73 }
75 }
74 Button {
76 Button {
75 text: "series hpos +"
77 text: "series hpos +"
76 onClicked: series.horizontalPosition += 0.1;
78 onClicked: series.horizontalPosition += 0.1;
77 }
79 }
78 Button {
80 Button {
79 text: "series hpos -"
81 text: "series hpos -"
80 onClicked: series.horizontalPosition -= 0.1;
82 onClicked: series.horizontalPosition -= 0.1;
81 }
83 }
82 Button {
84 Button {
83 text: "series vpos +"
85 text: "series vpos +"
84 onClicked: series.verticalPosition += 0.1;
86 onClicked: series.verticalPosition += 0.1;
85 }
87 }
86 Button {
88 Button {
87 text: "series vpos -"
89 text: "series vpos -"
88 onClicked: series.verticalPosition -= 0.1;
90 onClicked: series.verticalPosition -= 0.1;
89 }
91 }
90 Button {
92 Button {
91 text: "series size +"
93 text: "series size +"
92 onClicked: series.size += 0.1;
94 onClicked: series.size += 0.1;
93 }
95 }
94 Button {
96 Button {
95 text: "series size -"
97 text: "series size -"
96 onClicked: series.size -= 0.1;
98 onClicked: series.size -= 0.1;
97 }
99 }
98 Button {
100 Button {
99 text: "series start angle +"
101 text: "series start angle +"
100 onClicked: series.startAngle += 1.1;
102 onClicked: series.startAngle += 1.1;
101 }
103 }
102 Button {
104 Button {
103 text: "series start angle -"
105 text: "series start angle -"
104 onClicked: series.startAngle -= 1.1;
106 onClicked: series.startAngle -= 1.1;
105 }
107 }
106 Button {
108 Button {
107 text: "series end angle +"
109 text: "series end angle +"
108 onClicked: series.endAngle += 1.1;
110 onClicked: series.endAngle += 1.1;
109 }
111 }
110 Button {
112 Button {
111 text: "series end angle -"
113 text: "series end angle -"
112 onClicked: series.endAngle -= 1.1;
114 onClicked: series.endAngle -= 1.1;
113 }
115 }
114 Button {
116 Button {
115 text: "slice color"
117 text: "slice color"
116 onClicked: series.at(0).color = main.nextColor();
118 onClicked: series.at(0).color = main.nextColor();
117 }
119 }
118 Button {
120 Button {
119 text: "slice border color"
121 text: "slice border color"
120 onClicked: series.at(0).borderColor = main.nextColor();
122 onClicked: series.at(0).borderColor = main.nextColor();
121 }
123 }
122 Button {
124 Button {
123 text: "slice border width +"
125 text: "slice border width +"
124 onClicked: series.at(0).borderWidth++;
126 onClicked: series.at(0).borderWidth++;
125 }
127 }
126 Button {
128 Button {
127 text: "slice border width -"
129 text: "slice border width -"
128 onClicked: series.at(0).borderWidth--;
130 onClicked: series.at(0).borderWidth--;
129 }
131 }
130 Button {
132 Button {
131 text: "slice label visible"
133 text: "slice label visible"
132 onClicked: series.at(0).labelVisible = !series.at(0).labelVisible;
134 onClicked: series.at(0).labelVisible = !series.at(0).labelVisible;
133 }
135 }
134 Button {
136 Button {
135 text: "slice label position inside"
137 text: "slice label position inside"
136 onClicked: series.at(0).labelPosition = PieSlice.LabelInside;
138 onClicked: series.at(0).labelPosition = PieSlice.LabelInside;
137 }
139 }
138 Button {
140 Button {
139 text: "slice label position outside"
141 text: "slice label position outside"
140 onClicked: series.at(0).labelPosition = PieSlice.LabelOutside;
142 onClicked: series.at(0).labelPosition = PieSlice.LabelOutside;
141 }
143 }
142 Button {
144 Button {
143 text: "slice label arm len +"
145 text: "slice label arm len +"
144 onClicked: series.at(0).labelArmLengthFactor += 0.1;
146 onClicked: series.at(0).labelArmLengthFactor += 0.1;
145 }
147 }
146 Button {
148 Button {
147 text: "slice label arm len -"
149 text: "slice label arm len -"
148 onClicked: series.at(0).labelArmLengthFactor -= 0.1;
150 onClicked: series.at(0).labelArmLengthFactor -= 0.1;
149 }
151 }
150 Button {
152 Button {
151 text: "slice label color"
153 text: "slice label color"
152 onClicked: series.at(0).labelColor = main.nextColor();
154 onClicked: series.at(0).labelColor = main.nextColor();
153 }
155 }
154 Button {
156 Button {
155 text: "slice exploded"
157 text: "slice exploded"
156 onClicked: series.at(0).exploded = !series.at(0).exploded;
158 onClicked: series.at(0).exploded = !series.at(0).exploded;
157 }
159 }
158 Button {
160 Button {
159 text: "slice explode dist +"
161 text: "slice explode dist +"
160 onClicked: series.at(0).explodeDistanceFactor += 0.1;
162 onClicked: series.at(0).explodeDistanceFactor += 0.1;
161 }
163 }
162 Button {
164 Button {
163 text: "slice explode dist -"
165 text: "slice explode dist -"
164 onClicked: series.at(0).explodeDistanceFactor -= 0.1;
166 onClicked: series.at(0).explodeDistanceFactor -= 0.1;
165 }
167 }
166 }
168 }
General Comments 0
You need to be logged in to leave comments. Login now