1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,46 | |||||
|
1 | /*! | |||
|
2 | \example examples/lineandbar | |||
|
3 | \title Line and BarChart Example | |||
|
4 | \subtitle | |||
|
5 | ||||
|
6 | The example shows how to combine different charts and set the axes. In the example we combine linechart with | |||
|
7 | barchart and use category axis as common axis for both. | |||
|
8 | ||||
|
9 | \image examples_lineandbar.png | |||
|
10 | ||||
|
11 | Here we create data for our barseries. | |||
|
12 | ||||
|
13 | \snippet ../examples/lineandbar/main.cpp 1 | |||
|
14 | ||||
|
15 | We create the barseries and append the sets to it. | |||
|
16 | First value of each set are gropuped together at first category second value to second category and so on. | |||
|
17 | ||||
|
18 | \snippet ../examples/lineandbar/main.cpp 2 | |||
|
19 | ||||
|
20 | 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 | |||
|
21 | first point is at (0,value) second at (1,value) and so on. | |||
|
22 | ||||
|
23 | \snippet ../examples/lineandbar/main.cpp 8 | |||
|
24 | ||||
|
25 | Here we create the chart and add both series to it. | |||
|
26 | ||||
|
27 | \snippet ../examples/lineandbar/main.cpp 3 | |||
|
28 | ||||
|
29 | 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 | |||
|
30 | 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 | |||
|
31 | axis. For x-axis we use QBarCategoryAxis and for y-axis we use QValuesAxis. | |||
|
32 | ||||
|
33 | \snippet ../examples/lineandbar/main.cpp 4 | |||
|
34 | ||||
|
35 | And we also want to show the legend. | |||
|
36 | ||||
|
37 | \snippet ../examples/lineandbar/main.cpp 5 | |||
|
38 | ||||
|
39 | Finally we add the chart onto a view. | |||
|
40 | ||||
|
41 | \snippet ../examples/lineandbar/main.cpp 6 | |||
|
42 | ||||
|
43 | And it is ready to be shown in a window. | |||
|
44 | ||||
|
45 | \snippet ../examples/lineandbar/main.cpp 7 | |||
|
46 | */ |
@@ -18,6 +18,7 | |||||
18 | <li><a href="examples-customchart.html">Custom chart</a></li> |
|
18 | <li><a href="examples-customchart.html">Custom chart</a></li> | |
19 | <li><a href="examples-legend.html">Legend</a></li> |
|
19 | <li><a href="examples-legend.html">Legend</a></li> | |
20 | <li><a href="examples-linechart.html">Line chart</a></li> |
|
20 | <li><a href="examples-linechart.html">Line chart</a></li> | |
|
21 | <li><a href="examples-lineandbar.html">Line and barchart</a></li> | |||
21 | <li><a href="examples-modeldata.html">Model data</a></li> |
|
22 | <li><a href="examples-modeldata.html">Model data</a></li> | |
22 | <li><a href="examples-barmodelmapper.html">Bar chart from model</a></li> |
|
23 | <li><a href="examples-barmodelmapper.html">Bar chart from model</a></li> | |
23 | <li><a href="examples-percentbarchart.html">Percent bar chart</a></li> |
|
24 | <li><a href="examples-percentbarchart.html">Percent bar chart</a></li> |
General Comments 0
You need to be logged in to leave comments.
Login now