@@ -1,49 +1,49 | |||||
1 | /*! |
|
1 | /*! | |
2 |
\example |
|
2 | \example demos/nesteddonuts | |
3 |
\title |
|
3 | \title Nested donuts demo | |
4 | \subtitle |
|
4 | \subtitle | |
5 |
|
5 | |||
6 | This example shows how to use create a nested donuts chart using QPieSeries API. |
|
6 | This example shows how to use create a nested donuts chart using QPieSeries API. | |
7 | \image examples_donutchart.png |
|
7 | \image examples_donutchart.png | |
8 |
|
8 | |||
9 | Let's start by creating a QChartView instance and enabling the Antialiasing on it. Last line enables the animations of the chart. |
|
9 | Let's start by creating a QChartView instance and enabling the Antialiasing on it. Last line enables the animations of the chart. | |
10 |
|
10 | |||
11 |
\snippet ../ |
|
11 | \snippet ../demos/nesteddonuts/widget.cpp 1 | |
12 |
|
12 | |||
13 | Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut. |
|
13 | Three variables are defined that will be used to define the donut chart. Min and max size define the relative size of the whole donut. | |
14 | minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut. |
|
14 | minSize is the relative inner size of the smallest donut. maxSize is the relative outer size of the biggest donut. | |
15 |
|
15 | |||
16 |
\snippet ../ |
|
16 | \snippet ../demos/nesteddonuts/widget.cpp 2 | |
17 |
|
17 | |||
18 | Following block of code defines the individual donuts and their slices. First new QPieSeries object is created. |
|
18 | Following block of code defines the individual donuts and their slices. First new QPieSeries object is created. | |
19 | Callign setDonut() changes pie into a donut. The number of slices in each donut is randomized. |
|
19 | Callign setDonut() changes pie into a donut. The number of slices in each donut is randomized. | |
20 | The internal for loop creates the slices with a random value and label same as the value. |
|
20 | The internal for loop creates the slices with a random value and label same as the value. | |
21 | Next the label of the slice is set to be visible and its color is set to white. |
|
21 | Next the label of the slice is set to be visible and its color is set to white. | |
22 | To make the example more interesting the hovered signal of the slice is connected to widget's slot which inner workings are explained later. |
|
22 | To make the example more interesting the hovered signal of the slice is connected to widget's slot which inner workings are explained later. | |
23 | Finally the slice is added to the donut. The donut's size is adjusted to achive the nesting of the donuts. |
|
23 | Finally the slice is added to the donut. The donut's size is adjusted to achive the nesting of the donuts. | |
24 | Then the donut is added to the widget's list of donuts and to the chart. |
|
24 | Then the donut is added to the widget's list of donuts and to the chart. | |
25 |
|
25 | |||
26 |
\snippet ../ |
|
26 | \snippet ../demos/nesteddonuts/widget.cpp 3 | |
27 |
|
27 | |||
28 | Finally the widget is placed in a layout used by the application. |
|
28 | Finally the widget is placed in a layout used by the application. | |
29 |
|
29 | |||
30 |
\snippet ../ |
|
30 | \snippet ../demos/nesteddonuts/widget.cpp 4 | |
31 |
|
31 | |||
32 | To make the example more interesting the donuts are rotated randomly every 1.25 sec. |
|
32 | To make the example more interesting the donuts are rotated randomly every 1.25 sec. | |
33 |
|
33 | |||
34 |
\snippet ../ |
|
34 | \snippet ../demos/nesteddonuts/widget.cpp 5 | |
35 |
|
35 | |||
36 | The widget's updatedRotation slot is defined below. |
|
36 | The widget's updatedRotation slot is defined below. | |
37 | It goes through all of the donuts and modifies thier current rotation by a random value. |
|
37 | It goes through all of the donuts and modifies thier current rotation by a random value. | |
38 |
|
38 | |||
39 |
\snippet ../ |
|
39 | \snippet ../demos/nesteddonuts/widget.cpp 6 | |
40 |
|
40 | |||
41 | The earlier mentioned explodeSlice slot code is provided below. |
|
41 | The earlier mentioned explodeSlice slot code is provided below. | |
42 | If the slice is set to exploded then stop the timer that controls the donuts rotation. |
|
42 | If the slice is set to exploded then stop the timer that controls the donuts rotation. | |
43 | Then the slice's start and end agles are obtained from the slice. |
|
43 | Then the slice's start and end agles are obtained from the slice. | |
44 | To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice |
|
44 | To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice | |
45 | have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice. |
|
45 | have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice. | |
46 | If the slice is no longer selected return to the original state. |
|
46 | If the slice is no longer selected return to the original state. | |
47 |
|
47 | |||
48 |
\snippet ../ |
|
48 | \snippet ../demos/nesteddonuts/widget.cpp 7 | |
49 | */ |
|
49 | */ |
@@ -1,30 +1,31 | |||||
1 | /*! |
|
1 | /*! | |
2 | \page demos.html |
|
2 | \page demos.html | |
3 | \title Demos |
|
3 | \title Demos | |
4 | \keyword Demos |
|
4 | \keyword Demos | |
5 |
|
5 | |||
6 | \raw HTML |
|
6 | \raw HTML | |
7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> |
|
7 | <table cellpadding="2" cellspacing="1" border="0" width="100%" class="indextable"> | |
8 | <tr> |
|
8 | <tr> | |
9 | <th class="titleheader" width="33%"> |
|
9 | <th class="titleheader" width="33%"> | |
10 | List of demos |
|
10 | List of demos | |
11 | </th> |
|
11 | </th> | |
12 | </tr> |
|
12 | </tr> | |
13 | <tr> |
|
13 | <tr> | |
14 | <td valign="top"> |
|
14 | <td valign="top"> | |
15 | <ul> |
|
15 | <ul> | |
16 | <li><a href="demos-chartthemes.html">Chart themes</a></li> |
|
16 | <li><a href="demos-chartthemes.html">Chart themes</a></li> | |
17 | <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li> |
|
17 | <li><a href="demos-piechartcustomization.html">Pie chart customization</a></li> | |
18 | <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li> |
|
18 | <li><a href="demos-dynamicspline.html">Dynamic spline chart</a></li> | |
|
19 | <li><a href="demos-nesteddonuts.html">Nested donuts chart</a></li> | |||
19 | <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li> |
|
20 | <li><a href="demos-qmlchart.html">Qml Basic Charts</a></li> | |
20 | <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li> |
|
21 | <li><a href="demos-qmlcustomizations.html">Qml Customizations</a></li> | |
21 | <li><a href="demos-qmlweather.html">Qml Weather</a></li> |
|
22 | <li><a href="demos-qmlweather.html">Qml Weather</a></li> | |
22 | <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li> |
|
23 | <li><a href="demos-qmlf1legends.html">Qml F1 Legends</a></li> | |
23 | <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li> |
|
24 | <li><a href="demos-qmlcustommodel.html">Qml Custom Model</a></li> | |
24 | <li><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></li> |
|
25 | <li><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></li> | |
25 | </ul> |
|
26 | </ul> | |
26 | </td> |
|
27 | </td> | |
27 | </tr> |
|
28 | </tr> | |
28 | </table> |
|
29 | </table> | |
29 | \endraw |
|
30 | \endraw | |
30 | */ |
|
31 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now