@@ -8,7 +8,8 | |||||
8 | \image examples_barchart.png |
|
8 | \image examples_barchart.png | |
9 |
|
9 | |||
10 | Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data |
|
10 | Data that barchart visualizes, is defined by QBarSet instances. Here we create some sets and append data | |
11 |
we want to visualize to them. Note that |
|
11 | we want to visualize to them. Note that x positions are not in even intervals and this will be reflected in the chart. | |
|
12 | If x positions aren't defined, then the index of value is assumed to be x position. | |||
12 |
|
13 | |||
13 | \snippet ../examples/barchart/main.cpp 1 |
|
14 | \snippet ../examples/barchart/main.cpp 1 | |
14 |
|
15 | |||
@@ -17,6 +18,7 | |||||
17 | \snippet ../examples/barchart/main.cpp 2 |
|
18 | \snippet ../examples/barchart/main.cpp 2 | |
18 |
|
19 | |||
19 | Next we create a chart and add the series to it. |
|
20 | Next we create a chart and add the series to it. | |
|
21 | We also set the title for chart | |||
20 |
|
22 | |||
21 | \snippet ../examples/barchart/main.cpp 3 |
|
23 | \snippet ../examples/barchart/main.cpp 3 | |
22 |
|
24 |
@@ -7,22 +7,21 | |||||
7 |
|
7 | |||
8 | \image examples_groupedbarchart.png |
|
8 | \image examples_groupedbarchart.png | |
9 |
|
9 | |||
10 | First we define categories. |
|
10 | Data that groupedbarchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | |
|
11 | to them. | |||
11 |
|
12 | |||
12 | \snippet ../examples/groupedbarchart/main.cpp 1 |
|
13 | \snippet ../examples/groupedbarchart/main.cpp 1 | |
13 |
|
14 | |||
14 | Data that groupedbarchart visualizes, is defined by QBarSet instances. Here we create some sets and append data |
|
15 | We create the series and append the sets to it. The grouped barseries groups the data from sets to categories. | |
15 | we want to visualize to them. |
|
16 | First value of each set are gropuped together at first category second value to second category and so on. | |
16 |
|
17 | |||
17 | \snippet ../examples/groupedbarchart/main.cpp 2 |
|
18 | \snippet ../examples/groupedbarchart/main.cpp 2 | |
18 |
|
19 | |||
19 | To combine the sets and categories to a chart, we need to create QBarSeries instance. When creating |
|
20 | Then we create a chart and add the series to it. | |
20 | the QBarSeries, the categories must be known. Sets can be added later. For example purposes the sets |
|
|||
21 | are added to series here. |
|
|||
22 |
|
21 | |||
23 | \snippet ../examples/groupedbarchart/main.cpp 3 |
|
22 | \snippet ../examples/groupedbarchart/main.cpp 3 | |
24 |
|
23 | |||
25 | Then we create a chart and add the series to it. |
|
24 | We define the categories here and add them to the x-axis. | |
26 |
|
25 | |||
27 | \snippet ../examples/groupedbarchart/main.cpp 4 |
|
26 | \snippet ../examples/groupedbarchart/main.cpp 4 | |
28 |
|
27 |
@@ -55,7 +55,7 int main(int argc, char *argv[]) | |||||
55 | //![3] |
|
55 | //![3] | |
56 | QChart* chart = new QChart(); |
|
56 | QChart* chart = new QChart(); | |
57 | chart->addSeries(series); |
|
57 | chart->addSeries(series); | |
58 |
chart->setTitle(" |
|
58 | chart->setTitle("Barchart example"); | |
59 | //![3] |
|
59 | //![3] | |
60 |
|
60 | |||
61 | //![4] |
|
61 | //![4] |
@@ -47,7 +47,6 int main(int argc, char *argv[]) | |||||
47 |
|
47 | |||
48 | //![2] |
|
48 | //![2] | |
49 | QGroupedBarSeries* series = new QGroupedBarSeries(); |
|
49 | QGroupedBarSeries* series = new QGroupedBarSeries(); | |
50 | // series->setCategories(categories); |
|
|||
51 | series->append(set0); |
|
50 | series->append(set0); | |
52 | series->append(set1); |
|
51 | series->append(set1); | |
53 | series->append(set2); |
|
52 | series->append(set2); |
General Comments 0
You need to be logged in to leave comments.
Login now