|
@@
-1,44
+1,44
|
|
1
|
/*!
|
|
1
|
/*!
|
|
2
|
\example examples/donutdrilldown
|
|
2
|
\example examples/donutbreakdown
|
|
3
|
\title Donut chart drilldown example
|
|
3
|
\title Donut chart breakdown example
|
|
4
|
\subtitle
|
|
4
|
\subtitle
|
|
5
|
|
|
5
|
|
|
6
|
This example shows how to use create a donut drilldown chart using QPieSeries API.
|
|
6
|
This example shows how to use create a donut breakdown chart using QPieSeries API.
|
|
7
|
|
|
7
|
|
|
8
|
Let's start by creating a QChartView instance and enabling the Antialiasing on it. Last line enables the animations of the chart.
|
|
8
|
Let's start by creating a QChartView instance and enabling the Antialiasing on it. Last line enables the animations of the chart.
|
|
9
|
|
|
9
|
|
|
10
|
\snippet ../examples/donutdrilldown/widget.cpp 1
|
|
10
|
\snippet ../examples/donutbreakdown/widget.cpp 1
|
|
11
|
|
|
11
|
|
|
12
|
PieSeries is used to present the general data.
|
|
12
|
PieSeries is used to present the general data.
|
|
13
|
|
|
13
|
|
|
14
|
\snippet ../examples/donutdrilldown/widget.cpp 2
|
|
14
|
\snippet ../examples/donutbreakdown/widget.cpp 2
|
|
15
|
|
|
15
|
|
|
16
|
Following block of code creates the slices for the mainData QPieSeries.
|
|
16
|
Following block of code creates the slices for the mainData QPieSeries.
|
|
17
|
Then for every created slice a new series is created that stores the detailed data.
|
|
17
|
Then for every created slice a new series is created that stores the detailed data.
|
|
18
|
The details series is set to be a donut. Its size is adjusted so that it wraps around the mainData pie.
|
|
18
|
The details series is set to be a donut. Its size is adjusted so that it wraps around the mainData pie.
|
|
19
|
Next two signals from the mainData pie's slices are connected. This is used to keep the mainData slices agligned with their respective details series.
|
|
19
|
Next two signals from the mainData pie's slices are connected. This is used to keep the mainData slices agligned with their respective details series.
|
|
20
|
|
|
20
|
|
|
21
|
\snippet ../examples/donutdrilldown/widget.cpp 3
|
|
21
|
\snippet ../examples/donutbreakdown/widget.cpp 3
|
|
22
|
|
|
22
|
|
|
23
|
Set the labels of the mainData to enabled and their postion to Outside.
|
|
23
|
Set the labels of the mainData to enabled and their postion to Outside.
|
|
24
|
Then add the mainData and detailedData series to the chart.
|
|
24
|
Then add the mainData and detailedData series to the chart.
|
|
25
|
|
|
25
|
|
|
26
|
\snippet ../examples/donutdrilldown/widget.cpp 4
|
|
26
|
\snippet ../examples/donutbreakdown/widget.cpp 4
|
|
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 ../examples/donutdrilldown/widget.cpp 5
|
|
30
|
\snippet ../examples/donutbreakdown/widget.cpp 5
|
|
31
|
|
|
31
|
|
|
32
|
To show that the detailed data stays aligned with the main data every 2.5 sec. one of the slices is modified.
|
|
32
|
To show that the detailed data stays aligned with the main data every 2.5 sec. one of the slices is modified.
|
|
33
|
It should be noted that int this example the mainData slices should not be modified directly as the change
|
|
33
|
It should be noted that int this example the mainData slices should not be modified directly as the change
|
|
34
|
cannot be applied to the detailed slices without the extra knowledge on how the split looks like.
|
|
34
|
cannot be applied to the detailed slices without the extra knowledge on how the split looks like.
|
|
35
|
|
|
35
|
|
|
36
|
\snippet ../examples/donutdrilldown/widget.cpp 6
|
|
36
|
\snippet ../examples/donutbreakdown/widget.cpp 6
|
|
37
|
|
|
37
|
|
|
38
|
When the mainData slice layout is changed the detailed data layout has to be modified accordingly.
|
|
38
|
When the mainData slice layout is changed the detailed data layout has to be modified accordingly.
|
|
39
|
This is achived by setting the start and end angle of the detailed series.
|
|
39
|
This is achived by setting the start and end angle of the detailed series.
|
|
40
|
|
|
40
|
|
|
41
|
\snippet ../examples/donutdrilldown/widget.cpp 7
|
|
41
|
\snippet ../examples/donutbreakdown/widget.cpp 7
|
|
42
|
|
|
42
|
|
|
43
|
Highlight slot selects a random slice for the modification.
|
|
43
|
Highlight slot selects a random slice for the modification.
|
|
44
|
The slice is set to exploded to notify the user that its going to be changed.
|
|
44
|
The slice is set to exploded to notify the user that its going to be changed.
|
|
@@
-47,6
+47,6
|
|
47
|
Then the slice is modified. Respective mainData slice is modified as well to contain as the value the sum of the detailed series slices values.
|
|
47
|
Then the slice is modified. Respective mainData slice is modified as well to contain as the value the sum of the detailed series slices values.
|
|
48
|
Finally the slice exploded state is set to false.
|
|
48
|
Finally the slice exploded state is set to false.
|
|
49
|
|
|
49
|
|
|
50
|
\snippet ../examples/donutdrilldown/widget.cpp 8
|
|
50
|
\snippet ../examples/donutbreakdown/widget.cpp 8
|
|
51
|
|
|
51
|
|
|
52
|
*/
|
|
52
|
*/
|