##// END OF EJS Templates
Fix Charts documentation...
Fix Charts documentation The documentation structure is changed so that it can be generated with both Qt5 and Qt4. Also the erroneous VBarModelMapper is removed from VBoxPlotModelMapper documentation. Task-number: QTRD-2492, QTRD-2495 Change-Id: I45028915ca55f6ff1170db58518a8f08ac4158fb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>

File last commit:

r2610:66fa88d10640
r2639:2ce3423968b5
Show More
examples-stackedbarchartdrilldown.qdoc
45 lines | 2.8 KiB | text/plain | TextLexer
/ doc / src / examples-stackedbarchartdrilldown.qdoc
/*!
\example examples/stackedbarchartdrilldown
\title StackedBarChart Drilldown Example
\subtitle
The example shows how to implement drilldown using a stacked barchart. In thedrilldown example we create a stacked bar chart, 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, right-click the selected month. On weekly view, the harvest of the month clicked is shown by week.
The season view looks like this:
\image examples_stackedbarchartdrilldown1.png
Clicking on a month shows that month's harvest:
\image examples_stackedbarchartdrilldown2.png
First we define a drilldown series class, which adds categories to the stacked bar series and mapping for categories to other drilldown series.
The purpose of the drilldown series is to contain knowledge of the drilldown structure. The mapDrilldownSeries function maps the category to a given series. We can request the mapping for a category with the drilldownSeries(int category) function.
\snippet ../examples/stackedbarchartdrilldown/drilldownseries.h 1
Next we define our own drilldown chart, which implements the handler for the mouse click. All QBarSeries derived classes send out the clicked(QBarSet*, int) signal when a series is clicked with the mouse. The parameter QBarSet contains the pointer to the clicked bar set and parameter int contains the index of the clicked category.
\snippet ../examples/stackedbarchartdrilldown/drilldownchart.h 1
Now we have our drilldown classes and we can start using them.
First create the chart.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 1
We define the categories from which the drilldown series will be constructed.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 2
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.
In weeklySeries, we use the drilldown handler to bring us back to seasonSeries. To do so we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
To make mapping work, we connect the clicked signals from our series to the drilldownChart.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 3
When we have our drilldown structure ready, we can add the data to it. Here we generate a random crop for each plant in each week. The monthly crop is calculated from weekly crops and is set as value to the monthly series.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 4
Here we set the chart to show the top level series initially.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 5
*/