|
@@
-1,42
+1,42
|
|
1
|
/*!
|
|
1
|
/*!
|
|
2
|
\example examples/stackedbarchartdrilldown
|
|
2
|
\example examples/stackedbarchartdrilldown
|
|
3
|
\title StackedBarChart Drilldown Example
|
|
3
|
\title StackedBarChart Drilldown Example
|
|
4
|
\subtitle
|
|
4
|
\subtitle
|
|
5
|
|
|
5
|
|
|
6
|
The example shows how to implement drilldown using stacked barchart. In drilldown example we create stacked barchart, which shows the harvest of various chili peppers during season. In season view the harvest is grouped by month. To drill down to weekly view, user clicks selected month with right mouse button. On weekly view, the harvest of clicked month is shown by week. For example purposes each month is 4 weeks long :)
|
|
6
|
The example shows how to implement drilldown using stacked barchart. In drilldown example we create stacked barchart, which shows the harvest of various chili peppers during season. In season view the harvest is grouped by month. To drill down to weekly view, user clicks selected month with right mouse button. On weekly view, the harvest of clicked month is shown by week. For example purposes each month is 4 weeks long :)
|
|
7
|
|
|
7
|
|
|
8
|
Season view looks like this:
|
|
8
|
Season view looks like this:
|
|
9
|
\image stackedbarchart_drilldown_season.png
|
|
9
|
\image examples_stackedbarchartdrilldown1.png
|
|
10
|
|
|
10
|
|
|
11
|
Right mouse button clicked on august, shows the harvest from august:
|
|
11
|
Mouse button clicked on a month, shows the harvest from that month:
|
|
12
|
\image stackedbarchart_drilldown_august.png
|
|
12
|
\image examples_stackedbarchartdrilldown2.png
|
|
13
|
|
|
13
|
|
|
14
|
Here we define a drilldown series, which adds mapping for categories to other drilldown series.
|
|
14
|
Here we define a drilldown series, which adds mapping for categories to other drilldown series.
|
|
15
|
Purpose of drilldown series is to contain knowledge of the drilldown structure. The mapDrilldownSeries function maps the category to given series. We can ask the mapping for category with drilldownSeries(QString category) function.
|
|
15
|
Purpose of drilldown series is to contain knowledge of the drilldown structure. The mapDrilldownSeries function maps the category to given series. We can ask the mapping for category with drilldownSeries(QString category) function.
|
|
16
|
|
|
16
|
|
|
17
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 1
|
|
17
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 1
|
|
18
|
|
|
18
|
|
|
19
|
To enable drilldown we create own view, which implements handler for right click. All QBarSeries derived classes send out rightClicked(QBarSet*, QString) signal when series is clicked with right mouse button. The parameters QBarSet and QString contain the pointer to clicked bar set and name of category, where click occurred.
|
|
19
|
To enable drilldown we create own view, which implements handler for right click. All QBarSeries derived classes send out rightClicked(QBarSet*, QString) signal when series is clicked with right mouse button. The parameters QBarSet and QString contain the pointer to clicked bar set and name of category, where click occurred.
|
|
20
|
|
|
20
|
|
|
21
|
In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
|
|
21
|
In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
|
|
22
|
|
|
22
|
|
|
23
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 2
|
|
23
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 2
|
|
24
|
|
|
24
|
|
|
25
|
Here we define data, which we use to construct the chart.
|
|
25
|
Here we define data, which we use to construct the chart.
|
|
26
|
|
|
26
|
|
|
27
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 3
|
|
27
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 3
|
|
28
|
|
|
28
|
|
|
29
|
To create the drilldown structure, we first create our top level series, which we call seasonSeries. For each month in seasonSeries we create a drilldown series, called weeklySeries which contains more detailed data for that month.
|
|
29
|
To create the drilldown structure, we first create our top level series, which we call seasonSeries. For each month in seasonSeries we create a drilldown series, called weeklySeries which contains more detailed data for that month.
|
|
30
|
In weeklySeries, we use the drilldown handler to bring us back to seasonSeries. To do this we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
|
|
30
|
In weeklySeries, we use the drilldown handler to bring us back to seasonSeries. To do this we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
|
|
31
|
To make mapping work, we connect the rightClicked signals from our series to the drilldownChart.
|
|
31
|
To make mapping work, we connect the rightClicked signals from our series to the drilldownChart.
|
|
32
|
|
|
32
|
|
|
33
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 4
|
|
33
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 4
|
|
34
|
|
|
34
|
|
|
35
|
When we have our drilldown structure ready, we can add the data to it. Here we generate random crop for each plant in each week. The monthly crop is calculated from weekly crops. To enable floating values, we connect the clicked signal to toggle the value of corresponding set.
|
|
35
|
When we have our drilldown structure ready, we can add the data to it. Here we generate random crop for each plant in each week. The monthly crop is calculated from weekly crops. To enable floating values, we connect the clicked signal to toggle the value of corresponding set.
|
|
36
|
|
|
36
|
|
|
37
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 5
|
|
37
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 5
|
|
38
|
|
|
38
|
|
|
39
|
Here we set the chart to show top level series initially.
|
|
39
|
Here we set the chart to show top level series initially.
|
|
40
|
|
|
40
|
|
|
41
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 6
|
|
41
|
\snippet ../examples/stackedbarchartdrilldown/main.cpp 6
|
|
42
|
*/
|
|
42
|
*/
|