##// END OF EJS Templates
Fixing example documentation
Fixing example documentation

File last commit:

r500:4d73e3f9e3b6
r500:4d73e3f9e3b6
Show More
examples-stackedbarchart-drilldown.qdoc
41 lines | 2.8 KiB | text/plain | TextLexer
/ doc / src / examples-stackedbarchart-drilldown.qdoc
sauimone
Documentation for stacked barchart drilldown example
r462 /*!
Tero Ahola
Fixing example documentation
r500 \example examples/stackedbarchartdrilldown
sauimone
Documentation for stacked barchart drilldown example
r462 \title StackedBarChart Drilldown Example
\subtitle
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 :)
Season view looks like this:
\image stackedbarchart_drilldown_season.png
Right mouse button clicked on august, shows the harvest from august:
\image stackedbarchart_drilldown_august.png
Here we define a drilldown series, which adds mapping for categories to other drilldown series.
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.
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 1
sauimone
Documentation for stacked barchart drilldown example
r462
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 occured.
In our DrilldownChart we implement handler, which selects the drilldown chart with the category.
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 2
sauimone
Documentation for stacked barchart drilldown example
r462
Here we define data, which we use to construct the chart.
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 3
sauimone
Documentation for stacked barchart drilldown example
r462
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.
sauimone
Clarified drilldown documentation
r463 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.
To make mapping work, we connect the rightClicked signals from our series to the drilldownChart.
sauimone
Documentation for stacked barchart drilldown example
r462
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 4
sauimone
Documentation for stacked barchart drilldown example
r462
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.
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 5
sauimone
Documentation for stacked barchart drilldown example
r462
Here we set the chart to show top level series initially.
sauimone
fixed example paths in barchart documentation
r492 \snippet ../examples/stackedbarchartdrilldown/main.cpp 6
sauimone
Documentation for stacked barchart drilldown example
r462 */