##// END OF EJS Templates
Polishing on examples...
Polishing on examples Change-Id: I1cf77318e5551a79bfe31983bb2f770c80f9b976 Reviewed-by: Mika Salmela <mika.salmela@digia.com>

File last commit:

r2456:4278a56d8f51
r2536:c9bd72facaf8
Show More
examples-lineandbarchart.qdoc
46 lines | 1.6 KiB | text/plain | TextLexer
/ doc / src / examples-lineandbarchart.qdoc
/*!
\example examples/lineandbar
\title Line and BarChart Example
\subtitle
The example shows how to combine different charts and set the axes. In the example we combine linechart with
barchart and use category axis as common axis for both.
\image examples_lineandbar.png
Here we create data for our barseries.
\snippet ../examples/lineandbar/main.cpp 1
We create the barseries and append the sets to it.
First values of each set are grouped together at first category second value to second category and so on.
\snippet ../examples/lineandbar/main.cpp 2
Then we create lineseries and add data to it. To make data match with barchart we use index as an x-value for our line series, so that
first point is at (0,value) second at (1,value) and so on.
\snippet ../examples/lineandbar/main.cpp 8
Here we create the chart and add both series to it.
\snippet ../examples/lineandbar/main.cpp 3
To make chart show series properly, we have to create custom axes for series. If we don't create custom axes, then each series will get scaled to
use maximum area of the chart (like in single series case) and result will be incorrect. With custom axes we set the range of both series to follow same
axis. For x-axis we use QBarCategoryAxis and for y-axis we use QValuesAxis.
\snippet ../examples/lineandbar/main.cpp 4
And we also want to show the legend.
\snippet ../examples/lineandbar/main.cpp 5
Finally we add the chart onto a view.
\snippet ../examples/lineandbar/main.cpp 6
And it is ready to be shown in a window.
\snippet ../examples/lineandbar/main.cpp 7
*/