##// END OF EJS Templates
QCategoryAxis: fix to grid lines drawing
QCategoryAxis: fix to grid lines drawing

File last commit:

r1415:3a9150ae63dc
r1938:48e529a684ff
Show More
examples-stackedbarchartdrilldown.qdoc
45 lines | 2.8 KiB | text/plain | TextLexer
/ doc / src / examples-stackedbarchartdrilldown.qdoc
Jani Honkonen
Add all examples to docs
r919 /*!
\example examples/stackedbarchartdrilldown
Jani Honkonen
Put bar drilldown docs back.
r920 \title StackedBarChart Drilldown Example
Jani Honkonen
Add all examples to docs
r919 \subtitle
Jani Honkonen
Put bar drilldown docs back.
r920 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:
Tero Ahola
Updated screens for bar and presenter examples
r1411 \image examples_stackedbarchartdrilldown1.png
Jani Honkonen
Put bar drilldown docs back.
r920
Tero Ahola
Updated screens for bar and presenter examples
r1411 Mouse button clicked on a month, shows the harvest from that month:
\image examples_stackedbarchartdrilldown2.png
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 First we define a drilldown series class, which adds categories to stacked bar series and 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(int category) function.
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 \snippet ../examples/stackedbarchartdrilldown/drilldownseries.h 1
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 Next we define our own drilldown chart, which implements handler for mouse click. All QBarSeries derived classes send out clicked(QBarSet*, int) signal when series is clicked with mouse. The parameter QBarSet contains pointer to clicked bar set and parameter int contains the index of clicked category.
\snippet ../examples/stackedbarchartdrilldown/drilldownchart.h 1
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 Now we have our drilldown classes and we can start using them.
First create the chart.
\snippet ../examples/stackedbarchartdrilldown/main.cpp 1
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 We define categories, from wich the drilldown series will be constructed.
Jani Honkonen
Put bar drilldown docs back.
r920 \snippet ../examples/stackedbarchartdrilldown/main.cpp 2
sauimone
stacked bar drilldown example documentation update
r1415
Jani Honkonen
Put bar drilldown docs back.
r920 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 this we add mapping to the series. The seasonSeries is mapped to weeklySeries for each month. Every weeklySeries is mapped back to the seasonSeries.
sauimone
stacked bar drilldown example documentation update
r1415 To make mapping work, we connect the clicked signals from our series to the drilldownChart.
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 \snippet ../examples/stackedbarchartdrilldown/main.cpp 3
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 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 and is set as value to monthly series.
Jani Honkonen
Put bar drilldown docs back.
r920
sauimone
stacked bar drilldown example documentation update
r1415 \snippet ../examples/stackedbarchartdrilldown/main.cpp 4
Jani Honkonen
Put bar drilldown docs back.
r920
Here we set the chart to show top level series initially.
sauimone
stacked bar drilldown example documentation update
r1415 \snippet ../examples/stackedbarchartdrilldown/main.cpp 5
Jani Honkonen
Add all examples to docs
r919 */