@@ -1,92 +1,93 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QBarSeries> |
|
24 | #include <QBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QBarCategoryAxis> |
|
27 | #include <QBarCategoryAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | int main(int argc, char *argv[]) |
|
31 | int main(int argc, char *argv[]) | |
32 | { |
|
32 | { | |
33 | QApplication a(argc, argv); |
|
33 | QApplication a(argc, argv); | |
34 |
|
34 | |||
35 | //![1] |
|
35 | //![1] | |
36 | QBarSet *set0 = new QBarSet("Jane"); |
|
36 | QBarSet *set0 = new QBarSet("Jane"); | |
37 | QBarSet *set1 = new QBarSet("John"); |
|
37 | QBarSet *set1 = new QBarSet("John"); | |
38 | QBarSet *set2 = new QBarSet("Axel"); |
|
38 | QBarSet *set2 = new QBarSet("Axel"); | |
39 | QBarSet *set3 = new QBarSet("Mary"); |
|
39 | QBarSet *set3 = new QBarSet("Mary"); | |
40 | QBarSet *set4 = new QBarSet("Samantha"); |
|
40 | QBarSet *set4 = new QBarSet("Samantha"); | |
41 |
|
41 | |||
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
47 | //![1] |
|
47 | //![1] | |
48 |
|
48 | |||
49 | //![2] |
|
49 | //![2] | |
50 | QBarSeries* series = new QBarSeries(); |
|
50 | QBarSeries* series = new QBarSeries(); | |
51 | series->append(set0); |
|
51 | series->append(set0); | |
52 | series->append(set1); |
|
52 | series->append(set1); | |
53 | series->append(set2); |
|
53 | series->append(set2); | |
54 | series->append(set3); |
|
54 | series->append(set3); | |
55 | series->append(set4); |
|
55 | series->append(set4); | |
56 |
|
56 | |||
57 | //![2] |
|
57 | //![2] | |
58 |
|
58 | |||
59 | //![3] |
|
59 | //![3] | |
60 | QChart* chart = new QChart(); |
|
60 | QChart* chart = new QChart(); | |
61 | chart->addSeries(series); |
|
61 | chart->addSeries(series); | |
62 | chart->setTitle("Simple barchart example"); |
|
62 | chart->setTitle("Simple barchart example"); | |
|
63 | chart->setAnimationOptions(QChart::SeriesAnimations); | |||
63 | //![3] |
|
64 | //![3] | |
64 |
|
65 | |||
65 | //![4] |
|
66 | //![4] | |
66 | QStringList categories; |
|
67 | QStringList categories; | |
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
68 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
69 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
69 | axis->append(categories); |
|
70 | axis->append(categories); | |
70 | chart->createDefaultAxes(); |
|
71 | chart->createDefaultAxes(); | |
71 | chart->setAxisX(axis,series); |
|
72 | chart->setAxisX(axis,series); | |
72 | //![4] |
|
73 | //![4] | |
73 |
|
74 | |||
74 | //![5] |
|
75 | //![5] | |
75 | chart->legend()->setVisible(true); |
|
76 | chart->legend()->setVisible(true); | |
76 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
77 | chart->legend()->setAlignment(Qt::AlignBottom); | |
77 | //![5] |
|
78 | //![5] | |
78 |
|
79 | |||
79 | //![6] |
|
80 | //![6] | |
80 | QChartView* chartView = new QChartView(chart); |
|
81 | QChartView* chartView = new QChartView(chart); | |
81 | chartView->setRenderHint(QPainter::Antialiasing); |
|
82 | chartView->setRenderHint(QPainter::Antialiasing); | |
82 | //![6] |
|
83 | //![6] | |
83 |
|
84 | |||
84 | //![7] |
|
85 | //![7] | |
85 | QMainWindow window; |
|
86 | QMainWindow window; | |
86 | window.setCentralWidget(chartView); |
|
87 | window.setCentralWidget(chartView); | |
87 | window.resize(400, 300); |
|
88 | window.resize(400, 300); | |
88 | window.show(); |
|
89 | window.show(); | |
89 | //![7] |
|
90 | //![7] | |
90 |
|
91 | |||
91 | return a.exec(); |
|
92 | return a.exec(); | |
92 | } |
|
93 | } |
@@ -1,92 +1,93 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QPercentBarSeries> |
|
24 | #include <QPercentBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QBarCategoryAxis> |
|
27 | #include <QBarCategoryAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | int main(int argc, char *argv[]) |
|
31 | int main(int argc, char *argv[]) | |
32 | { |
|
32 | { | |
33 | QApplication a(argc, argv); |
|
33 | QApplication a(argc, argv); | |
34 |
|
34 | |||
35 | //![1] |
|
35 | //![1] | |
36 | QBarSet *set0 = new QBarSet("Jane"); |
|
36 | QBarSet *set0 = new QBarSet("Jane"); | |
37 | QBarSet *set1 = new QBarSet("John"); |
|
37 | QBarSet *set1 = new QBarSet("John"); | |
38 | QBarSet *set2 = new QBarSet("Axel"); |
|
38 | QBarSet *set2 = new QBarSet("Axel"); | |
39 | QBarSet *set3 = new QBarSet("Mary"); |
|
39 | QBarSet *set3 = new QBarSet("Mary"); | |
40 | QBarSet *set4 = new QBarSet("Samantha"); |
|
40 | QBarSet *set4 = new QBarSet("Samantha"); | |
41 |
|
41 | |||
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
47 | //![1] |
|
47 | //![1] | |
48 |
|
48 | |||
49 | //![2] |
|
49 | //![2] | |
50 | QPercentBarSeries* series = new QPercentBarSeries(); |
|
50 | QPercentBarSeries* series = new QPercentBarSeries(); | |
51 | series->append(set0); |
|
51 | series->append(set0); | |
52 | series->append(set1); |
|
52 | series->append(set1); | |
53 | series->append(set2); |
|
53 | series->append(set2); | |
54 | series->append(set3); |
|
54 | series->append(set3); | |
55 | series->append(set4); |
|
55 | series->append(set4); | |
56 | //![2] |
|
56 | //![2] | |
57 |
|
57 | |||
58 | //![3] |
|
58 | //![3] | |
59 | QChart* chart = new QChart(); |
|
59 | QChart* chart = new QChart(); | |
60 | chart->addSeries(series); |
|
60 | chart->addSeries(series); | |
61 | chart->setTitle("Simple percentbarchart example"); |
|
61 | chart->setTitle("Simple percentbarchart example"); | |
|
62 | chart->setAnimationOptions(QChart::SeriesAnimations); | |||
62 | //![3] |
|
63 | //![3] | |
63 |
|
64 | |||
64 | //![4] |
|
65 | //![4] | |
65 | QStringList categories; |
|
66 | QStringList categories; | |
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
67 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
68 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
68 | axis->append(categories); |
|
69 | axis->append(categories); | |
69 | chart->createDefaultAxes(); |
|
70 | chart->createDefaultAxes(); | |
70 | chart->setAxisX(axis,series); |
|
71 | chart->setAxisX(axis,series); | |
71 | //![4] |
|
72 | //![4] | |
72 |
|
73 | |||
73 | //![5] |
|
74 | //![5] | |
74 | chart->legend()->setVisible(true); |
|
75 | chart->legend()->setVisible(true); | |
75 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
76 | chart->legend()->setAlignment(Qt::AlignBottom); | |
76 | //![5] |
|
77 | //![5] | |
77 |
|
78 | |||
78 | //![6] |
|
79 | //![6] | |
79 | QChartView* chartView = new QChartView(chart); |
|
80 | QChartView* chartView = new QChartView(chart); | |
80 | chartView->setRenderHint(QPainter::Antialiasing); |
|
81 | chartView->setRenderHint(QPainter::Antialiasing); | |
81 | //![6] |
|
82 | //![6] | |
82 |
|
83 | |||
83 | //![7] |
|
84 | //![7] | |
84 | QMainWindow window; |
|
85 | QMainWindow window; | |
85 | window.setCentralWidget(chartView); |
|
86 | window.setCentralWidget(chartView); | |
86 | window.resize(400, 300); |
|
87 | window.resize(400, 300); | |
87 | window.show(); |
|
88 | window.show(); | |
88 | //![7] |
|
89 | //![7] | |
89 |
|
90 | |||
90 | return a.exec(); |
|
91 | return a.exec(); | |
91 | } |
|
92 | } | |
92 |
|
93 |
@@ -1,92 +1,93 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QStackedBarSeries> |
|
24 | #include <QStackedBarSeries> | |
25 | #include <QBarSet> |
|
25 | #include <QBarSet> | |
26 | #include <QLegend> |
|
26 | #include <QLegend> | |
27 | #include <QBarCategoryAxis> |
|
27 | #include <QBarCategoryAxis> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
30 |
|
30 | |||
31 | int main(int argc, char *argv[]) |
|
31 | int main(int argc, char *argv[]) | |
32 | { |
|
32 | { | |
33 | QApplication a(argc, argv); |
|
33 | QApplication a(argc, argv); | |
34 |
|
34 | |||
35 | //![1] |
|
35 | //![1] | |
36 | QBarSet *set0 = new QBarSet("Jane"); |
|
36 | QBarSet *set0 = new QBarSet("Jane"); | |
37 | QBarSet *set1 = new QBarSet("John"); |
|
37 | QBarSet *set1 = new QBarSet("John"); | |
38 | QBarSet *set2 = new QBarSet("Axel"); |
|
38 | QBarSet *set2 = new QBarSet("Axel"); | |
39 | QBarSet *set3 = new QBarSet("Mary"); |
|
39 | QBarSet *set3 = new QBarSet("Mary"); | |
40 | QBarSet *set4 = new QBarSet("Samantha"); |
|
40 | QBarSet *set4 = new QBarSet("Samantha"); | |
41 |
|
41 | |||
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
47 | //![1] |
|
47 | //![1] | |
48 |
|
48 | |||
49 | //![2] |
|
49 | //![2] | |
50 | QStackedBarSeries* series = new QStackedBarSeries(); |
|
50 | QStackedBarSeries* series = new QStackedBarSeries(); | |
51 | series->append(set0); |
|
51 | series->append(set0); | |
52 | series->append(set1); |
|
52 | series->append(set1); | |
53 | series->append(set2); |
|
53 | series->append(set2); | |
54 | series->append(set3); |
|
54 | series->append(set3); | |
55 | series->append(set4); |
|
55 | series->append(set4); | |
56 | //![2] |
|
56 | //![2] | |
57 |
|
57 | |||
58 | //![3] |
|
58 | //![3] | |
59 | QChart* chart = new QChart(); |
|
59 | QChart* chart = new QChart(); | |
60 | chart->addSeries(series); |
|
60 | chart->addSeries(series); | |
61 | chart->setTitle("Simple stackedbarchart example"); |
|
61 | chart->setTitle("Simple stackedbarchart example"); | |
|
62 | chart->setAnimationOptions(QChart::SeriesAnimations); | |||
62 | //![3] |
|
63 | //![3] | |
63 |
|
64 | |||
64 | //![4] |
|
65 | //![4] | |
65 | QStringList categories; |
|
66 | QStringList categories; | |
66 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
67 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
67 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
68 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
68 | axis->append(categories); |
|
69 | axis->append(categories); | |
69 | chart->createDefaultAxes(); |
|
70 | chart->createDefaultAxes(); | |
70 | chart->setAxisX(axis,series); |
|
71 | chart->setAxisX(axis,series); | |
71 | //![4] |
|
72 | //![4] | |
72 |
|
73 | |||
73 | //![5] |
|
74 | //![5] | |
74 | chart->legend()->setVisible(true); |
|
75 | chart->legend()->setVisible(true); | |
75 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
76 | chart->legend()->setAlignment(Qt::AlignBottom); | |
76 | //![5] |
|
77 | //![5] | |
77 |
|
78 | |||
78 | //![6] |
|
79 | //![6] | |
79 | QChartView* chartView = new QChartView(chart); |
|
80 | QChartView* chartView = new QChartView(chart); | |
80 | chartView->setRenderHint(QPainter::Antialiasing); |
|
81 | chartView->setRenderHint(QPainter::Antialiasing); | |
81 | //![6] |
|
82 | //![6] | |
82 |
|
83 | |||
83 | //![7] |
|
84 | //![7] | |
84 | QMainWindow window; |
|
85 | QMainWindow window; | |
85 | window.setCentralWidget(chartView); |
|
86 | window.setCentralWidget(chartView); | |
86 | window.resize(400, 300); |
|
87 | window.resize(400, 300); | |
87 | window.show(); |
|
88 | window.show(); | |
88 | //![7] |
|
89 | //![7] | |
89 |
|
90 | |||
90 | return a.exec(); |
|
91 | return a.exec(); | |
91 | } |
|
92 | } | |
92 |
|
93 |
General Comments 0
You need to be logged in to leave comments.
Login now