##// END OF EJS Templates
removed mention to Finland and modified temperatures in example to avoid possible copyright issues. Using fictional data now.
sauimone -
r1953:19301f21f096
parent child
Show More
@@ -1,86 +1,86
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include <QApplication>
22 22 #include <QMainWindow>
23 23 #include <QChartView>
24 24 #include <QBarSeries>
25 25 #include <QBarSet>
26 26 #include <QLegend>
27 27 #include <QBarCategoryAxis>
28 28 #include <QStackedBarSeries>
29 29
30 30 QTCOMMERCIALCHART_USE_NAMESPACE
31 31
32 32 int main(int argc, char *argv[])
33 33 {
34 34 QApplication a(argc, argv);
35 35
36 36 //![1]
37 37 QBarSet *low = new QBarSet("Min");
38 38 QBarSet *high = new QBarSet("Max");
39 39
40 *low << -51.5 << -49 << -44.3 << -36.0 << -24.6 << -7.0 << -5.0 << -10.8 << -18.7 << -31.8 << -42.0 << -47.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;
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 << 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 42 //![1]
43 43
44 44 //![2]
45 45 QStackedBarSeries *series = new QStackedBarSeries();
46 46 series->append(low);
47 47 series->append(high);
48 48 //![2]
49 49
50 50 //![3]
51 51 QChart* chart = new QChart();
52 52 chart->addSeries(series);
53 chart->setTitle("Temperature records in Finland in Celcius");
53 chart->setTitle("Temperature records in celcius");
54 54 chart->setAnimationOptions(QChart::SeriesAnimations);
55 55 //![3]
56 56
57 57 //![4]
58 58 QStringList categories;
59 59 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
60 60
61 61 QBarCategoryAxis* axis = new QBarCategoryAxis();
62 62 axis->append(categories);
63 63 chart->createDefaultAxes();
64 64 chart->setAxisX(axis,series);
65 65 chart->axisY(series)->setRange(-52,52);
66 66 //![4]
67 67
68 68 //![5]
69 69 chart->legend()->setVisible(true);
70 70 chart->legend()->setAlignment(Qt::AlignBottom);
71 71 //![5]
72 72
73 73 //![6]
74 74 QChartView* chartView = new QChartView(chart);
75 75 chartView->setRenderHint(QPainter::Antialiasing);
76 76 //![6]
77 77
78 78 //![7]
79 79 QMainWindow window;
80 80 window.setCentralWidget(chartView);
81 81 window.resize(400, 300);
82 82 window.show();
83 83 //![7]
84 84
85 85 return a.exec();
86 86 }
General Comments 0
You need to be logged in to leave comments. Login now