##// END OF EJS Templates
Pie doc updates
Jani Honkonen -
r880:be90a995df75
parent child
Show More
@@ -0,0 +1,7
1 /*!
2 \example examples/piechartdrilldown
3 \title Piechart drilldown example
4 \subtitle
5
6 The example shows how to implement a piechart with drilldown effect.
7 */
@@ -1,9 +1,7
1 1 /*!
2 2 \example examples/piechart
3 \title LineChart Example
3 \title Piechart Example
4 4 \subtitle
5 5
6 The example shows how to create simple pie chart.
7
8 ...
9 */ No newline at end of file
6 The example shows how to create simple pie chart and do some customizations to a pie slice.
7 */
@@ -1,32 +1,33
1 1 /*!
2 2 \page examples.html
3 3 \title Examples
4 4 \keyword Examples
5 5
6 6 \raw HTML
7 7 <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable">
8 8 <tr>
9 9 <th class="titleheader" width="33%">
10 10 List of examples
11 11 </th>
12 12 </tr>
13 13 <tr>
14 14 <td valign="top">
15 15 <ul>
16 <li><a href="examples-areachart.html">Area Chart example</a></li>
17 <li><a href="examples-barchart.html">Bar Chart example</a></li>
18 <li><a href="examples-linechart.html">Line Chart example</a></li>
19 <li><a href="examples-percentbarchart.html">Percent Bar Chart example</a></li>
20 <li><a href="examples-piechart.html">Pie Chart example</a></li>
21 <li><a href="examples-presenterchart.html">Presenter Chart example</a></li>
22 <li><a href="examples-scatterchart.html">Scatter Chart example</a></li>
23 <li><a href="examples-splinechart.html">Spline Chart example</a></li>
24 <li><a href="examples-stackedbarchart.html">Stacked Bar Chart example</a></li>
25 <li><a href="examples-stackedbarchartdrilldown.html">Stacked Bar Chart Drilldown example</a></li>
16 <li><a href="examples-areachart.html">Area chart example</a></li>
17 <li><a href="examples-barchart.html">Bar chart example</a></li>
18 <li><a href="examples-linechart.html">Line chart example</a></li>
19 <li><a href="examples-percentbarchart.html">Percent bar chart example</a></li>
20 <li><a href="examples-piechart.html">Pie chart example</a></li>
21 <li><a href="examples-piechartdrilldown.html">Pie chart drilldown example</a></li>
22 <li><a href="examples-presenterchart.html">Presenter chart example</a></li>
23 <li><a href="examples-scatterchart.html">Scatter chart example</a></li>
24 <li><a href="examples-splinechart.html">Spline chart example</a></li>
25 <li><a href="examples-stackedbarchart.html">Stacked bar chart example</a></li>
26 <li><a href="examples-stackedbarchartdrilldown.html">Stacked bar chart drilldown example</a></li>
26 27 <li><a href="examples-customcolors.html">Customizing colors example</a></li>
27 28 </ul>
28 29 </td>
29 30 </tr>
30 31 </table>
31 32 \endraw
32 33 */
@@ -1,65 +1,69
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QApplication>
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QPieSeries>
25 25 #include <QPieSlice>
26 26
27 27 QTCOMMERCIALCHART_USE_NAMESPACE
28 28
29 29 int main(int argc, char *argv[])
30 30 {
31 31 QApplication a(argc, argv);
32 32
33 33 //![1]
34 34 QPieSeries *series = new QPieSeries();
35 35 series->append(1, "Slice 1");
36 36 series->append(2, "Slice 2");
37 37 series->append(3, "Slice 3");
38 38 series->append(4, "Slice 4");
39 39 series->append(5, "Slice 5");
40 40 //![1]
41 41
42 42 //![2]
43 43 QPieSlice *slice = series->slices().first();
44 44 slice->setExploded();
45 45 slice->setLabelVisible();
46 46 slice->setPen(QPen(Qt::darkGreen, 2));
47 47 slice->setBrush(Qt::green);
48 48 //![2]
49
49 50 //![3]
50 51 QChart* chart = new QChart();
51 52 chart->addSeries(series);
52 53 chart->setTitle("Simple piechart example");
53 54 //![3]
55
54 56 //![4]
55 57 QChartView* chartView = new QChartView(chart);
56 58 chartView->setRenderHint(QPainter::Antialiasing);
57 59 //![4]
60
58 61 //![5]
59 62 QMainWindow window;
60 63 window.setCentralWidget(chartView);
61 64 window.resize(400, 300);
62 65 window.show();
63 66 //![5]
67
64 68 return a.exec();
65 69 }
@@ -1,402 +1,400
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qpieslice.h"
22 22 #include "pieslicedata_p.h"
23 23
24 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25
26 26 /*!
27 27 \class QPieSlice
28 28 \brief Defines a slice in pie series.
29 29
30 30 Holds all the data of a single slice in a QPieSeries and provides the means
31 31 to modify slice data and customize the visual appearance of the slice.
32 32
33 33 It also provides the means to customize user interaction with the slice by
34 34 providing signals for clicking and hover events.
35 35 */
36 36
37 37 /*!
38 38 \property QPieSlice::label
39 39
40 40 Label of the slice.
41 41 */
42 42
43 43 /*!
44 44 \property QPieSlice::value
45 45
46 46 Value of the slice.
47 47 */
48 48
49 49 /*!
50 50 Constructs an empty slice with a \a parent.
51 51
52 52 Note that QPieSeries takes ownership of the slice when it is set/added.
53 53
54 54 \sa QPieSeries::replace(), QPieSeries::append()
55 55 */
56 56 QPieSlice::QPieSlice(QObject *parent)
57 57 :QObject(parent),
58 58 d(new PieSliceData())
59 59 {
60 60
61 61 }
62 62
63 63 /*!
64 64 Constructs an empty slice with given \a value, \a label and a \a parent.
65 65 Note that QPieSeries takes ownership of the slice when it is set/added.
66 66 \sa QPieSeries::replace(), QPieSeries::append()
67 67 */
68 68 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
69 69 :QObject(parent),
70 70 d(new PieSliceData())
71 71 {
72 72 d->m_value = value;
73 73 d->m_labelText = label;
74 74 }
75 75
76 76 /*!
77 77 Destroys the slice.
78 78 User should not delete the slice if it has been added to the series.
79 79 */
80 80 QPieSlice::~QPieSlice()
81 81 {
82 82 delete d;
83 83 }
84 84
85 85 /*!
86 86 Gets the value of the slice.
87 87 Note that all values in the series
88 88 \sa setValue()
89 89 */
90 90 qreal QPieSlice::value() const
91 91 {
92 92 return d->m_value;
93 93 }
94 94
95 95 /*!
96 96 Gets the label of the slice.
97 97 \sa setLabel()
98 98 */
99 99 QString QPieSlice::label() const
100 100 {
101 101 return d->m_labelText;
102 102 }
103 103
104 104 /*!
105 105 Returns true if label is set as visible.
106 106 \sa setLabelVisible()
107 107 */
108 108 bool QPieSlice::isLabelVisible() const
109 109 {
110 110 return d->m_isLabelVisible;
111 111 }
112 112
113 113 /*!
114 114 Returns true if slice is exloded from the pie.
115 115 \sa setExploded(), setExplodeDistanceFactor()
116 116 */
117 117 bool QPieSlice::isExploded() const
118 118 {
119 119 return d->m_isExploded;
120 120 }
121 121
122 122 /*!
123 123 Returns the explode distance factor.
124 124
125 125 The factor is relative to pie radius. For example:
126 126 1.0 means the distance is the same as the radius.
127 127 0.5 means the distance is half of the radius.
128 128
129 129 Default value is 0.15.
130 130
131 131 \sa setExplodeDistanceFactor()
132 132 */
133 133 qreal QPieSlice::explodeDistanceFactor() const
134 134 {
135 135 return d->m_explodeDistanceFactor;
136 136 }
137 137
138 138 /*!
139 139 Returns the percentage of this slice compared to all slices in the same series.
140 140 The returned value ranges from 0 to 1.0.
141 141
142 142 Updated internally after the slice is added to the series.
143 143 */
144 144 qreal QPieSlice::percentage() const
145 145 {
146 146 return d->m_percentage;
147 147 }
148 148
149 149 /*!
150 150 Returns the starting angle of this slice in the series it belongs to.
151 151
152 152 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
153 153
154 154 Updated internally after the slice is added to the series.
155 155 */
156 156 qreal QPieSlice::startAngle() const
157 157 {
158 158 return d->m_startAngle;
159 159 }
160 160
161 161 /*!
162 162 Returns the end angle of this slice in the series it belongs to.
163 163
164 164 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
165 165
166 166 Updated internally after the slice is added to the series.
167 167 */
168 168 qreal QPieSlice::endAngle() const
169 169 {
170 170 return d->m_startAngle + d->m_angleSpan;
171 171 }
172 172
173 173 /*!
174 174 Returns the pen used to draw this slice.
175 175 \sa setPen()
176 176 */
177 177 QPen QPieSlice::pen() const
178 178 {
179 179 return d->m_slicePen;
180 180 }
181 181
182 182 /*!
183 183 Returns the brush used to draw this slice.
184 184 \sa setBrush()
185 185 */
186 186 QBrush QPieSlice::brush() const
187 187 {
188 188 return d->m_sliceBrush;
189 189 }
190 190
191 191 /*!
192 192 Returns the pen used to draw the label in this slice.
193 193 \sa setLabelPen()
194 194 */
195 195 QPen QPieSlice::labelPen() const
196 196 {
197 197 return d->m_labelPen;
198 198 }
199 199
200 200 /*!
201 201 Returns the font used to draw label in this slice.
202 202 \sa setLabelFont()
203 203 */
204 204 QFont QPieSlice::labelFont() const
205 205 {
206 206 return d->m_labelFont;
207 207 }
208 208
209 209 /*!
210 210 Gets the label arm length factor.
211 211
212 212 The factor is relative to pie radius. For example:
213 213 1.0 means the length is the same as the radius.
214 214 0.5 means the length is half of the radius.
215 215
216 216 Default value is 0.15
217 217
218 218 \sa setLabelArmLengthFactor()
219 219 */
220 220 qreal QPieSlice::labelArmLengthFactor() const
221 221 {
222 222 return d->m_labelArmLengthFactor;
223 223 }
224 224
225 225 /*!
226 226 \fn void QPieSlice::clicked(Qt::MouseButtons buttons)
227 227
228 228 This signal is emitted when user has clicked the slice.
229 229
230 230 \sa QPieSeries::clicked()
231 231 */
232 232
233 233 /*!
234 234 \fn void QPieSlice::hoverEnter()
235 235
236 236 This signal is emitted when user has hovered over the slice.
237 237
238 238 \sa QPieSeries::hoverEnter()
239 239 */
240 240
241 241 /*!
242 242 \fn void QPieSlice::hoverLeave()
243 243
244 244 This signal is emitted when user has hovered away from the slice.
245 245
246 246 \sa QPieSeries::hoverLeave()
247 247 */
248 248
249 249 /*!
250 250 \fn void QPieSlice::changed()
251 251
252 252 This signal emitted when something has changed in the slice.
253
254 \sa QPieSeries::changed()
255 253 */
256 254
257 255 /*!
258 256 Sets the \a value of this slice.
259 257 \sa value()
260 258 */
261 259 void QPieSlice::setValue(qreal value)
262 260 {
263 261 if (!qFuzzyIsNull(d->m_value - value)) {
264 262 d->m_value = value;
265 263 emit changed();
266 264 }
267 265 }
268 266
269 267 /*!
270 268 Sets the \a label of the slice.
271 269 \sa label()
272 270 */
273 271 void QPieSlice::setLabel(QString label)
274 272 {
275 273 if (d->m_labelText != label) {
276 274 d->m_labelText = label;
277 275 emit changed();
278 276 }
279 277 }
280 278
281 279 /*!
282 280 Sets the label \a visible in this slice.
283 281 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
284 282 */
285 283 void QPieSlice::setLabelVisible(bool visible)
286 284 {
287 285 if (d->m_isLabelVisible != visible) {
288 286 d->m_isLabelVisible = visible;
289 287 emit changed();
290 288 }
291 289 }
292 290
293 291 /*!
294 292 Sets this slice \a exploded.
295 293 \sa isExploded(), explodeDistanceFactor()
296 294 */
297 295 void QPieSlice::setExploded(bool exploded)
298 296 {
299 297 if (d->m_isExploded != exploded) {
300 298 d->m_isExploded = exploded;
301 299 emit changed();
302 300 }
303 301 }
304 302
305 303 /*!
306 304 Sets the explode distance \a factor.
307 305
308 306 The factor is relative to pie radius. For example:
309 307 1.0 means the distance is the same as the radius.
310 308 0.5 means the distance is half of the radius.
311 309
312 310 Default value is 0.15
313 311
314 312 \sa explodeDistanceFactor()
315 313 */
316 314 void QPieSlice::setExplodeDistanceFactor(qreal factor)
317 315 {
318 316 if (!qFuzzyIsNull(d->m_explodeDistanceFactor - factor)) {
319 317 d->m_explodeDistanceFactor = factor;
320 318 emit changed();
321 319 }
322 320 }
323 321
324 322 /*!
325 323 Sets the \a pen used to draw this slice.
326 324 Note that applying a theme will override this.
327 325 \sa pen()
328 326 */
329 327 void QPieSlice::setPen(const QPen &pen)
330 328 {
331 329 if (d->m_slicePen != pen) {
332 330 d->m_slicePen = pen;
333 331 d->m_slicePen.setThemed(false);
334 332 emit changed();
335 333 }
336 334 }
337 335
338 336 /*!
339 337 Sets the \a brush used to draw this slice.
340 338 Note that applying a theme will override this.
341 339 \sa brush()
342 340 */
343 341 void QPieSlice::setBrush(const QBrush &brush)
344 342 {
345 343 if (d->m_sliceBrush != brush) {
346 344 d->m_sliceBrush = brush;
347 345 d->m_sliceBrush.setThemed(false);
348 346 emit changed();
349 347 }
350 348 }
351 349
352 350 /*!
353 351 Sets the \a pen used to draw the label in this slice.
354 352 Note that applying a theme will override this.
355 353 \sa labelPen()
356 354 */
357 355 void QPieSlice::setLabelPen(const QPen &pen)
358 356 {
359 357 if (d->m_labelPen != pen) {
360 358 d->m_labelPen = pen;
361 359 d->m_labelPen.setThemed(false);
362 360 emit changed();
363 361 }
364 362 }
365 363
366 364 /*!
367 365 Sets the \a font used to draw the label in this slice.
368 366 Note that applying a theme will override this.
369 367 \sa labelFont()
370 368 */
371 369 void QPieSlice::setLabelFont(const QFont &font)
372 370 {
373 371 if (d->m_labelFont != font) {
374 372 d->m_labelFont = font;
375 373 d->m_labelFont.setThemed(false);
376 374 emit changed();
377 375 }
378 376 }
379 377
380 378 /*!
381 379 Sets the label arm length \a factor.
382 380
383 381 The factor is relative to pie radius. For example:
384 382 1.0 means the length is the same as the radius.
385 383 0.5 means the length is half of the radius.
386 384
387 385 Default value is 0.15
388 386
389 387 \sa labelArmLengthFactor()
390 388 */
391 389 void QPieSlice::setLabelArmLengthFactor(qreal factor)
392 390 {
393 391 if (!qFuzzyIsNull(d->m_labelArmLengthFactor - factor)) {
394 392 d->m_labelArmLengthFactor = factor;
395 393 emit changed();
396 394 }
397 395 }
398 396
399 397 QTCOMMERCIALCHART_END_NAMESPACE
400 398
401 399 QTCOMMERCIALCHART_USE_NAMESPACE
402 400 #include "moc_qpieslice.cpp"
General Comments 0
You need to be logged in to leave comments. Login now