@@ -7,33 +7,41 | |||
|
7 | 7 | |
|
8 | 8 | \image examples_barchart.png |
|
9 | 9 | |
|
10 | The barsets are used in same way in all barcharts. | |
|
11 | To illustrate difference between various barcharts, we use same data in examples. | |
|
10 | 12 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data |
|
11 | to them. | |
|
13 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
12 | 14 | |
|
13 | 15 | \snippet ../examples/barchart/main.cpp 1 |
|
14 | 16 | |
|
15 | We create the series and append the sets to it. The barseries groups the data from sets to categories. | |
|
17 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
16 | 18 | First value of each set are gropuped together at first category second value to second category and so on. |
|
17 | 19 | |
|
18 | 20 | \snippet ../examples/barchart/main.cpp 2 |
|
19 | 21 | |
|
20 | Then we create a chart and add the series to it. | |
|
22 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
23 | setAnimationOptions(QChart::SeriesAnimations) | |
|
21 | 24 | |
|
22 | 25 | \snippet ../examples/barchart/main.cpp 3 |
|
23 | 26 | |
|
24 | We define the categories here and add them to QCategoriesAxis which we then set to be the x-axis of the chart. | |
|
27 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
28 | set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data | |
|
29 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
30 | override the category axis. | |
|
25 | 31 | |
|
26 | 32 | \snippet ../examples/barchart/main.cpp 4 |
|
27 | 33 | |
|
28 | And we also want to show the legend. | |
|
34 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
35 | to Qt::AlignBottom. | |
|
29 | 36 | |
|
30 | 37 | \snippet ../examples/barchart/main.cpp 5 |
|
31 | 38 | |
|
32 | Finally we add the chart onto a view. | |
|
39 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
33 | 40 | |
|
34 | 41 | \snippet ../examples/barchart/main.cpp 6 |
|
35 | 42 | |
|
36 | And it is ready to be shown in a window. | |
|
43 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
44 | We also set the size for the chart window and show it. | |
|
37 | 45 | |
|
38 | 46 | \snippet ../examples/barchart/main.cpp 7 |
|
39 | 47 | */ No newline at end of file |
@@ -3,37 +3,46 | |||
|
3 | 3 | \title HorizontalBarChart Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
|
6 | The example shows how to create a horizontal bar chart. HorizontalBarChart shows the data in sets as separate bars, which are grouped in categories. | |
|
6 | The example shows how to create a horizontal bar chart. QHorizontalBarChart shows the data in sets as separate bars, which are grouped in categories. QHorizontalBarChart works just like | |
|
7 | QBarChart, except that the bars are drawn horizontally on the chart. | |
|
7 | 8 | |
|
8 | 9 | \image examples_horizontalbarchart.png |
|
9 | 10 | |
|
11 | The barsets are used in same way in all barcharts. | |
|
12 | To illustrate difference between various barcharts, we use same data in examples. | |
|
10 | 13 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data |
|
11 | to them. | |
|
14 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
12 | 15 | |
|
13 | 16 | \snippet ../examples/horizontalbarchart/main.cpp 1 |
|
14 | 17 | |
|
15 |
We create the series and append the sets to it. The |
|
|
18 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
16 | 19 | First value of each set are gropuped together at first category second value to second category and so on. |
|
17 | 20 | |
|
18 | 21 | \snippet ../examples/horizontalbarchart/main.cpp 2 |
|
19 | 22 | |
|
20 | Then we create a chart and add the series to it. | |
|
23 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
24 | setAnimationOptions(QChart::SeriesAnimations) | |
|
21 | 25 | |
|
22 | 26 | \snippet ../examples/horizontalbarchart/main.cpp 3 |
|
23 | 27 | |
|
24 | We define the categories here and add them to QCategoriesAxis which we then set to be the x-axis of the chart. | |
|
28 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
29 | set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data | |
|
30 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
31 | override the category axis. | |
|
25 | 32 | |
|
26 | 33 | \snippet ../examples/horizontalbarchart/main.cpp 4 |
|
27 | 34 | |
|
28 | And we also want to show the legend. | |
|
35 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
36 | to Qt::AlignBottom. | |
|
29 | 37 | |
|
30 | 38 | \snippet ../examples/horizontalbarchart/main.cpp 5 |
|
31 | 39 | |
|
32 | Finally we add the chart onto a view. | |
|
40 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
33 | 41 | |
|
34 | 42 | \snippet ../examples/horizontalbarchart/main.cpp 6 |
|
35 | 43 | |
|
36 | And it is ready to be shown in a window. | |
|
44 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
45 | We also set the size for the chart window and show it. | |
|
37 | 46 | |
|
38 | 47 | \snippet ../examples/horizontalbarchart/main.cpp 7 |
|
39 | 48 | */ |
@@ -6,12 +6,48 | |||
|
6 | 6 | The example shows how to create simple horizontal percent bar chart. Horizontal percent bar chart shows the data in set as percentage of |
|
7 | 7 | all sets, per category. |
|
8 | 8 | |
|
9 | \image examples_horizontalpercentbarchart.png | |
|
10 | ||
|
11 | 9 | Creating horizontal percent bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a |
|
12 | 10 | horizontal percent bar chart, we use QHorizontalPercentBarSeries api instead of QBarSeries. Also, in the |
|
13 | 11 | \l {BarChart Example} {bar chart} we used nice numbers algorithm to make the y axis numbering look better. With |
|
14 | 12 | percent bar chart there is no need for that, because the maximum y-axis value is always 100. |
|
15 | 13 | |
|
14 | \image examples_horizontalpercentbarchart.png | |
|
15 | ||
|
16 | The barsets are used in same way in all barcharts. | |
|
17 | To illustrate difference between various barcharts, we use same data in examples. | |
|
18 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | |
|
19 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
20 | ||
|
21 | \snippet ../examples/horizontalpercentbarchart/main.cpp 1 | |
|
22 | ||
|
23 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
24 | First value of each set are gropuped together at first category second value to second category and so on. | |
|
25 | ||
|
26 | \snippet ../examples/horizontalpercentbarchart/main.cpp 2 | |
|
27 | ||
|
28 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
29 | setAnimationOptions(QChart::SeriesAnimations) | |
|
30 | ||
|
16 | 31 | \snippet ../examples/horizontalpercentbarchart/main.cpp 3 |
|
32 | ||
|
33 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
34 | set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data | |
|
35 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
36 | override the category axis. | |
|
37 | ||
|
38 | \snippet ../examples/horizontalpercentbarchart/main.cpp 4 | |
|
39 | ||
|
40 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
41 | to Qt::AlignBottom. | |
|
42 | ||
|
43 | \snippet ../examples/horizontalpercentbarchart/main.cpp 5 | |
|
44 | ||
|
45 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
46 | ||
|
47 | \snippet ../examples/horizontalpercentbarchart/main.cpp 6 | |
|
48 | ||
|
49 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
50 | We also set the size for the chart window and show it. | |
|
51 | ||
|
52 | \snippet ../examples/horizontalpercentbarchart/main.cpp 7 | |
|
17 | 53 | */ |
@@ -5,11 +5,46 | |||
|
5 | 5 | |
|
6 | 6 | The example shows how to create simple stacked horizontal bar chart. Stacked bar chart shows the data in sets as bars that are |
|
7 | 7 | stacked on top of each other. The stacking is done per category. |
|
8 | Creating stacked horizontal bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a | |
|
9 | stacked horizontal bar chart, we use QHorizontalStackedBarSeries api instead of QBarSeries. | |
|
8 | 10 | |
|
9 | 11 | \image examples_horizontalstackedbarchart.png |
|
10 | 12 | |
|
11 | Creating stacked horizontal bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a | |
|
12 | stacked horizontal bar chart, we use QHorizontalStackedBarSeries api instead of QBarSeries. | |
|
13 | The barsets are used in same way in all barcharts. | |
|
14 | To illustrate difference between various barcharts, we use same data in examples. | |
|
15 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | |
|
16 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
17 | ||
|
18 | \snippet ../examples/horizontalstackedbarchart/main.cpp 1 | |
|
19 | ||
|
20 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
21 | First value of each set are gropuped together at first category second value to second category and so on. | |
|
22 | ||
|
23 | \snippet ../examples/horizontalstackedbarchart/main.cpp 2 | |
|
24 | ||
|
25 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
26 | setAnimationOptions(QChart::SeriesAnimations) | |
|
13 | 27 | |
|
14 | 28 | \snippet ../examples/horizontalstackedbarchart/main.cpp 3 |
|
29 | ||
|
30 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
31 | set it to be the y-axis of the chart. The chart takes ownership of axis. For x-axis we use default axis, which is created and scaled to series data | |
|
32 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
33 | override the category axis. | |
|
34 | ||
|
35 | \snippet ../examples/horizontalstackedbarchart/main.cpp 4 | |
|
36 | ||
|
37 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
38 | to Qt::AlignBottom. | |
|
39 | ||
|
40 | \snippet ../examples/horizontalstackedbarchart/main.cpp 5 | |
|
41 | ||
|
42 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
43 | ||
|
44 | \snippet ../examples/horizontalstackedbarchart/main.cpp 6 | |
|
45 | ||
|
46 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
47 | We also set the size for the chart window and show it. | |
|
48 | ||
|
49 | \snippet ../examples/horizontalstackedbarchart/main.cpp 7 | |
|
15 | 50 | */ No newline at end of file |
@@ -6,12 +6,48 | |||
|
6 | 6 | The example shows how to create simple percent bar chart. Percent bar chart shows the data in set as percentage of |
|
7 | 7 | all sets, per category. |
|
8 | 8 | |
|
9 | \image examples_percentbarchart.png | |
|
10 | ||
|
11 | 9 | Creating percent bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a |
|
12 | 10 | percent bar chart, we use QPercentBarSeries api instead of QBarSeries. Also, in the |
|
13 | 11 | \l {BarChart Example} {bar chart} we used nice numbers algorithm to make the y axis numbering look better. With |
|
14 | 12 | percent bar chart there is no need for that, because the maximum y-axis value is always 100. |
|
15 | 13 | |
|
14 | \image examples_percentbarchart.png | |
|
15 | ||
|
16 | The barsets are used in same way in all barcharts. | |
|
17 | To illustrate difference between various barcharts, we use same data in examples. | |
|
18 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | |
|
19 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
20 | ||
|
21 | \snippet ../examples/percentbarchart/main.cpp 1 | |
|
22 | ||
|
23 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
24 | First value of each set are gropuped together at first category second value to second category and so on. | |
|
25 | ||
|
26 | \snippet ../examples/percentbarchart/main.cpp 2 | |
|
27 | ||
|
28 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
29 | setAnimationOptions(QChart::SeriesAnimations) | |
|
30 | ||
|
16 | 31 | \snippet ../examples/percentbarchart/main.cpp 3 |
|
32 | ||
|
33 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
34 | set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data | |
|
35 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
36 | override the category axis. | |
|
37 | ||
|
38 | \snippet ../examples/percentbarchart/main.cpp 4 | |
|
39 | ||
|
40 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
41 | to Qt::AlignBottom. | |
|
42 | ||
|
43 | \snippet ../examples/percentbarchart/main.cpp 5 | |
|
44 | ||
|
45 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
46 | ||
|
47 | \snippet ../examples/percentbarchart/main.cpp 6 | |
|
48 | ||
|
49 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
50 | We also set the size for the chart window and show it. | |
|
51 | ||
|
52 | \snippet ../examples/percentbarchart/main.cpp 7 | |
|
17 | 53 | */ |
@@ -5,11 +5,50 | |||
|
5 | 5 | |
|
6 | 6 | The example shows how to create simple stacked bar chart. Stacked bar chart shows the data in sets as bars that are |
|
7 | 7 | stacked on top of each other. The stacking is done per category. |
|
8 | The example shows how to create simple stacked bar chart. Stacked bar chart shows the data in sets as bars that are | |
|
9 | stacked on top of each other. The stacking is done per category. | |
|
10 | Creating stacked bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a | |
|
11 | stacked bar chart, we use QStackedBarSeries api instead of QBarSeries. | |
|
8 | 12 | |
|
9 | 13 | \image examples_stackedbarchart.png |
|
10 | 14 | |
|
11 | Creating stacked bar chart is just like creating a regular \l {BarChart Example} {bar chart}, except that for a | |
|
12 | stacked bar chart, we use QStackedBarSeries api instead of QBarSeries. | |
|
15 | The barsets are used in same way in all barcharts. | |
|
16 | To illustrate difference between various barcharts, we use same data in examples. | |
|
17 | Data that barchart visualizes, is defined by QBarSet instances. Here we create the sets and append data | |
|
18 | to them. The data is appended here with << operator. Alternatively the append method could be used. | |
|
19 | ||
|
20 | \snippet ../examples/stackedbarchart/main.cpp 1 | |
|
21 | ||
|
22 | We create the series and append the barsets to it. The series takes ownership of the barsets. The series groups the data from sets to categories. | |
|
23 | First value of each set are gropuped together at first category second value to second category and so on. | |
|
24 | ||
|
25 | \snippet ../examples/stackedbarchart/main.cpp 2 | |
|
26 | ||
|
27 | Here we create the chart object and add the series to it. We set the title for chart with setTitle and then turn on animations of the series by calling | |
|
28 | setAnimationOptions(QChart::SeriesAnimations) | |
|
13 | 29 | |
|
14 | 30 | \snippet ../examples/stackedbarchart/main.cpp 3 |
|
31 | ||
|
32 | To have categories displayed on axis, we need to create a QBarCategoryAxis for that. Here we create a category axis with list of categories and | |
|
33 | set it to be the x-axis of the chart. The chart takes ownership of axis. For y-axis we use default axis, which is created and scaled to series data | |
|
34 | by calling createDefaultAxes of the chart. Note that the call for createDefaultAxes must be before we set the category axis. Otherwise the default axis will | |
|
35 | override the category axis. | |
|
36 | ||
|
37 | \snippet ../examples/stackedbarchart/main.cpp 4 | |
|
38 | ||
|
39 | We also want to show the legend. To do that, we get the legend pointer from chart and set it to visible. We also place the legend to bottom of the chart by setting it's alignment | |
|
40 | to Qt::AlignBottom. | |
|
41 | ||
|
42 | \snippet ../examples/stackedbarchart/main.cpp 5 | |
|
43 | ||
|
44 | Finally we add the chart onto a view. We also turn on the antialiasing for the chartView. | |
|
45 | ||
|
46 | \snippet ../examples/stackedbarchart/main.cpp 6 | |
|
47 | ||
|
48 | Chart is ready to be shown. We set the chart to be central widget of the window. | |
|
49 | We also set the size for the chart window and show it. | |
|
50 | ||
|
51 | \snippet ../examples/stackedbarchart/main.cpp 7 | |
|
15 | 52 | */ |
|
53 | ||
|
54 |
@@ -60,7 +60,6 int main(int argc, char *argv[]) | |||
|
60 | 60 | QChart* chart = new QChart(); |
|
61 | 61 | chart->addSeries(series); |
|
62 | 62 | chart->setTitle("Simple barchart example"); |
|
63 | chart->createDefaultAxes(); | |
|
64 | 63 | //![3] |
|
65 | 64 | |
|
66 | 65 | //![4] |
@@ -68,6 +67,7 int main(int argc, char *argv[]) | |||
|
68 | 67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
69 | 68 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
70 | 69 | axis->append(categories); |
|
70 | chart->createDefaultAxes(); | |
|
71 | 71 | chart->setAxisX(axis,series); |
|
72 | 72 | //![4] |
|
73 | 73 |
@@ -54,14 +54,12 int main(int argc, char *argv[]) | |||
|
54 | 54 | series->append(set2); |
|
55 | 55 | series->append(set3); |
|
56 | 56 | series->append(set4); |
|
57 | ||
|
58 | 57 | //![2] |
|
59 | 58 | |
|
60 | 59 | //![3] |
|
61 | 60 | QChart* chart = new QChart(); |
|
62 | 61 | chart->addSeries(series); |
|
63 | 62 | chart->setTitle("Simple horizontal barchart example"); |
|
64 | chart->createDefaultAxes(); | |
|
65 | 63 | chart->setAnimationOptions(QChart::SeriesAnimations); |
|
66 | 64 | //![3] |
|
67 | 65 | |
@@ -70,6 +68,7 int main(int argc, char *argv[]) | |||
|
70 | 68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
71 | 69 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
72 | 70 | axis->append(categories); |
|
71 | chart->createDefaultAxes(); | |
|
73 | 72 | chart->setAxisY(axis,series); |
|
74 | 73 | //![4] |
|
75 | 74 |
@@ -61,7 +61,6 int main(int argc, char *argv[]) | |||
|
61 | 61 | QChart* chart = new QChart(); |
|
62 | 62 | chart->addSeries(series); |
|
63 | 63 | chart->setTitle("Simple horizontal percent barchart example"); |
|
64 | chart->createDefaultAxes(); | |
|
65 | 64 | chart->setAnimationOptions(QChart::SeriesAnimations); |
|
66 | 65 | //![3] |
|
67 | 66 |
@@ -61,7 +61,6 int main(int argc, char *argv[]) | |||
|
61 | 61 | QChart* chart = new QChart(); |
|
62 | 62 | chart->addSeries(series); |
|
63 | 63 | chart->setTitle("Simple horizontal stacked barchart example"); |
|
64 | chart->createDefaultAxes(); | |
|
65 | 64 | chart->setAnimationOptions(QChart::SeriesAnimations); |
|
66 | 65 | //![3] |
|
67 | 66 |
@@ -59,7 +59,6 int main(int argc, char *argv[]) | |||
|
59 | 59 | QChart* chart = new QChart(); |
|
60 | 60 | chart->addSeries(series); |
|
61 | 61 | chart->setTitle("Simple stackedbarchart example"); |
|
62 | chart->createDefaultAxes(); | |
|
63 | 62 | //![3] |
|
64 | 63 | |
|
65 | 64 | //![4] |
@@ -67,6 +66,7 int main(int argc, char *argv[]) | |||
|
67 | 66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
68 | 67 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
69 | 68 | axis->append(categories); |
|
69 | chart->createDefaultAxes(); | |
|
70 | 70 | chart->setAxisX(axis,series); |
|
71 | 71 | //![4] |
|
72 | 72 |
General Comments 0
You need to be logged in to leave comments.
Login now