@@ -1,86 +1,86 | |||||
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 <QStackedBarSeries> |
|
28 | #include <QStackedBarSeries> | |
29 |
|
29 | |||
30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | QTCOMMERCIALCHART_USE_NAMESPACE | |
31 |
|
31 | |||
32 | int main(int argc, char *argv[]) |
|
32 | int main(int argc, char *argv[]) | |
33 | { |
|
33 | { | |
34 | QApplication a(argc, argv); |
|
34 | QApplication a(argc, argv); | |
35 |
|
35 | |||
36 | //![1] |
|
36 | //![1] | |
37 | QBarSet *low = new QBarSet("Min"); |
|
37 | QBarSet *low = new QBarSet("Min"); | |
38 | QBarSet *high = new QBarSet("Max"); |
|
38 | QBarSet *high = new QBarSet("Max"); | |
39 |
|
39 | |||
40 |
*low << -5 |
|
40 | *low << -52 << -50 << -45.3 << -37.0 << -25.6 << -8.0 << -6.0 << -11.8 << -19.7 << -32.8 << -43.0 << -48.0; | |
41 | *high << 10.9 << 11.8 << 17.5 << 25.5 << 31.0 << 33.8 << 37.2 << 33.8 << 28.8 << 19.4 << 14.1 << 10.8; |
|
41 | *high << 11.9 << 12.8 << 18.5 << 26.5 << 32.0 << 34.8 << 38.2 << 34.8 << 29.8 << 20.4 << 15.1 << 11.8; | |
42 | //![1] |
|
42 | //![1] | |
43 |
|
43 | |||
44 | //![2] |
|
44 | //![2] | |
45 | QStackedBarSeries *series = new QStackedBarSeries(); |
|
45 | QStackedBarSeries *series = new QStackedBarSeries(); | |
46 | series->append(low); |
|
46 | series->append(low); | |
47 | series->append(high); |
|
47 | series->append(high); | |
48 | //![2] |
|
48 | //![2] | |
49 |
|
49 | |||
50 | //![3] |
|
50 | //![3] | |
51 | QChart* chart = new QChart(); |
|
51 | QChart* chart = new QChart(); | |
52 | chart->addSeries(series); |
|
52 | chart->addSeries(series); | |
53 |
chart->setTitle("Temperature records in |
|
53 | chart->setTitle("Temperature records in celcius"); | |
54 | chart->setAnimationOptions(QChart::SeriesAnimations); |
|
54 | chart->setAnimationOptions(QChart::SeriesAnimations); | |
55 | //![3] |
|
55 | //![3] | |
56 |
|
56 | |||
57 | //![4] |
|
57 | //![4] | |
58 | QStringList categories; |
|
58 | QStringList categories; | |
59 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
59 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; | |
60 |
|
60 | |||
61 | QBarCategoryAxis* axis = new QBarCategoryAxis(); |
|
61 | QBarCategoryAxis* axis = new QBarCategoryAxis(); | |
62 | axis->append(categories); |
|
62 | axis->append(categories); | |
63 | chart->createDefaultAxes(); |
|
63 | chart->createDefaultAxes(); | |
64 | chart->setAxisX(axis,series); |
|
64 | chart->setAxisX(axis,series); | |
65 | chart->axisY(series)->setRange(-52,52); |
|
65 | chart->axisY(series)->setRange(-52,52); | |
66 | //![4] |
|
66 | //![4] | |
67 |
|
67 | |||
68 | //![5] |
|
68 | //![5] | |
69 | chart->legend()->setVisible(true); |
|
69 | chart->legend()->setVisible(true); | |
70 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
70 | chart->legend()->setAlignment(Qt::AlignBottom); | |
71 | //![5] |
|
71 | //![5] | |
72 |
|
72 | |||
73 | //![6] |
|
73 | //![6] | |
74 | QChartView* chartView = new QChartView(chart); |
|
74 | QChartView* chartView = new QChartView(chart); | |
75 | chartView->setRenderHint(QPainter::Antialiasing); |
|
75 | chartView->setRenderHint(QPainter::Antialiasing); | |
76 | //![6] |
|
76 | //![6] | |
77 |
|
77 | |||
78 | //![7] |
|
78 | //![7] | |
79 | QMainWindow window; |
|
79 | QMainWindow window; | |
80 | window.setCentralWidget(chartView); |
|
80 | window.setCentralWidget(chartView); | |
81 | window.resize(400, 300); |
|
81 | window.resize(400, 300); | |
82 | window.show(); |
|
82 | window.show(); | |
83 | //![7] |
|
83 | //![7] | |
84 |
|
84 | |||
85 | return a.exec(); |
|
85 | return a.exec(); | |
86 | } |
|
86 | } |
General Comments 0
You need to be logged in to leave comments.
Login now