1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,93 +1,96 | |||||
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 | #include <QValueAxis> | |||
28 | #include <QHorizontalBarSeries> |
|
29 | #include <QHorizontalBarSeries> | |
29 |
|
30 | |||
30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
31 | QTCOMMERCIALCHART_USE_NAMESPACE | |
31 |
|
32 | |||
32 | int main(int argc, char *argv[]) |
|
33 | int main(int argc, char *argv[]) | |
33 | { |
|
34 | { | |
34 | QApplication a(argc, argv); |
|
35 | QApplication a(argc, argv); | |
35 |
|
36 | |||
36 | //![1] |
|
37 | //![1] | |
37 | QBarSet *set0 = new QBarSet("Jane"); |
|
38 | QBarSet *set0 = new QBarSet("Jane"); | |
38 | QBarSet *set1 = new QBarSet("John"); |
|
39 | QBarSet *set1 = new QBarSet("John"); | |
39 | QBarSet *set2 = new QBarSet("Axel"); |
|
40 | QBarSet *set2 = new QBarSet("Axel"); | |
40 | QBarSet *set3 = new QBarSet("Mary"); |
|
41 | QBarSet *set3 = new QBarSet("Mary"); | |
41 | QBarSet *set4 = new QBarSet("Samantha"); |
|
42 | QBarSet *set4 = new QBarSet("Samantha"); | |
42 |
|
43 | |||
43 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
44 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
44 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
45 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
45 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
46 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
46 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
47 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
47 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
48 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
48 | //![1] |
|
49 | //![1] | |
49 |
|
50 | |||
50 | //![2] |
|
51 | //![2] | |
51 | QHorizontalBarSeries *series = new QHorizontalBarSeries(); |
|
52 | QHorizontalBarSeries *series = new QHorizontalBarSeries(); | |
52 | series->append(set0); |
|
53 | series->append(set0); | |
53 | series->append(set1); |
|
54 | series->append(set1); | |
54 | series->append(set2); |
|
55 | series->append(set2); | |
55 | series->append(set3); |
|
56 | series->append(set3); | |
56 | series->append(set4); |
|
57 | series->append(set4); | |
57 | //![2] |
|
58 | //![2] | |
58 |
|
59 | |||
59 | //![3] |
|
60 | //![3] | |
60 | QChart *chart = new QChart(); |
|
61 | QChart *chart = new QChart(); | |
61 | chart->addSeries(series); |
|
62 | chart->addSeries(series); | |
62 | chart->setTitle("Simple horizontal barchart example"); |
|
63 | chart->setTitle("Simple horizontal barchart example"); | |
63 | chart->setAnimationOptions(QChart::SeriesAnimations); |
|
64 | chart->setAnimationOptions(QChart::SeriesAnimations); | |
64 | //![3] |
|
65 | //![3] | |
65 |
|
66 | |||
66 | //![4] |
|
67 | //![4] | |
67 | QStringList categories; |
|
68 | QStringList categories; | |
68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
69 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
69 | QBarCategoryAxis *axis = new QBarCategoryAxis(); |
|
70 | QBarCategoryAxis *axisY = new QBarCategoryAxis(); | |
70 | axis->append(categories); |
|
71 | axisY->append(categories); | |
71 | chart->createDefaultAxes(); |
|
72 | chart->setAxisY(axisY, series); | |
72 | chart->setAxisY(axis, series); |
|
73 | QValueAxis *axisX = new QValueAxis(); | |
|
74 | chart->setAxisX(axisX, series); | |||
|
75 | axisX->applyNiceNumbers(); | |||
73 | //![4] |
|
76 | //![4] | |
74 |
|
77 | |||
75 | //![5] |
|
78 | //![5] | |
76 | chart->legend()->setVisible(true); |
|
79 | chart->legend()->setVisible(true); | |
77 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
80 | chart->legend()->setAlignment(Qt::AlignBottom); | |
78 | //![5] |
|
81 | //![5] | |
79 |
|
82 | |||
80 | //![6] |
|
83 | //![6] | |
81 | QChartView *chartView = new QChartView(chart); |
|
84 | QChartView *chartView = new QChartView(chart); | |
82 | chartView->setRenderHint(QPainter::Antialiasing); |
|
85 | chartView->setRenderHint(QPainter::Antialiasing); | |
83 | //![6] |
|
86 | //![6] | |
84 |
|
87 | |||
85 | //![7] |
|
88 | //![7] | |
86 | QMainWindow window; |
|
89 | QMainWindow window; | |
87 | window.setCentralWidget(chartView); |
|
90 | window.setCentralWidget(chartView); | |
88 | window.resize(400, 300); |
|
91 | window.resize(400, 300); | |
89 | window.show(); |
|
92 | window.show(); | |
90 | //![7] |
|
93 | //![7] | |
91 |
|
94 | |||
92 | return a.exec(); |
|
95 | return a.exec(); | |
93 | } |
|
96 | } |
General Comments 0
You need to be logged in to leave comments.
Login now