@@ -1,82 +1,80 | |||||
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 |
|
27 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
29 | |||
30 | int main(int argc, char *argv[]) |
|
30 | int main(int argc, char *argv[]) | |
31 | { |
|
31 | { | |
32 | QApplication a(argc, argv); |
|
32 | QApplication a(argc, argv); | |
33 |
|
33 | |||
34 | //![1] |
|
34 | //![1] | |
35 | QBarSet *set0 = new QBarSet("Jane"); |
|
35 | QBarSet *set0 = new QBarSet("Jane"); | |
36 | QBarSet *set1 = new QBarSet("John"); |
|
36 | QBarSet *set1 = new QBarSet("John"); | |
37 | QBarSet *set2 = new QBarSet("Axel"); |
|
37 | QBarSet *set2 = new QBarSet("Axel"); | |
38 | QBarSet *set3 = new QBarSet("Mary"); |
|
38 | QBarSet *set3 = new QBarSet("Mary"); | |
39 | QBarSet *set4 = new QBarSet("Samantha"); |
|
|||
40 |
|
39 | |||
41 | *set0 << QPointF(0.0, 1) << QPointF(1.0, 2) << QPointF(2.4, 3) << QPointF(3.0, 4) << QPointF(4.0, 5) << QPointF(5.0, 6); |
|
40 | *set0 << QPointF(0.0, 1) << QPointF(1.0, 2) << QPointF(2.4, 3) << QPointF(3.0, 4) << QPointF(4.0, 5) << QPointF(5.0, 6); | |
42 | *set1 << QPointF(0.1, 2) << QPointF(1.2, 3) << QPointF(2.45, 4) << QPointF(3.2, 5) << QPointF(4.2, 6) << QPointF(5.2, 7); |
|
41 | *set1 << QPointF(0.1, 2) << QPointF(1.2, 3) << QPointF(2.45, 4) << QPointF(3.2, 5) << QPointF(4.2, 6) << QPointF(5.2, 7); | |
43 | *set2 << QPointF(0.2, 3) << QPointF(1.4, 4) << QPointF(2.50, 5) << QPointF(3.4, 6) << QPointF(4.4, 7) << QPointF(5.4, 8); |
|
42 | *set2 << QPointF(0.2, 3) << QPointF(1.4, 4) << QPointF(2.50, 5) << QPointF(3.4, 6) << QPointF(4.4, 7) << QPointF(5.4, 8); | |
44 | *set3 << QPointF(0.3, 4) << QPointF(1.6, 5) << QPointF(2.55, 6) << QPointF(3.6, 7) << QPointF(4.6, 8) << QPointF(5.6, 9); |
|
43 | *set3 << QPointF(0.3, 4) << QPointF(1.6, 5) << QPointF(2.55, 6) << QPointF(3.6, 7) << QPointF(4.6, 8) << QPointF(5.6, 9); | |
45 | *set4 << QPointF(0.4, 5) << QPointF(1.8, 6) << QPointF(2.6, 7) << QPointF(3.8, 8) << QPointF(4.8, 9) << QPointF(5.8, 10); |
|
|||
46 | //![1] |
|
44 | //![1] | |
47 |
|
45 | |||
48 | //![2] |
|
46 | //![2] | |
49 | QBarSeries* series = new QBarSeries(); |
|
47 | QBarSeries* series = new QBarSeries(); | |
|
48 | series->setBarMargin(0.8); | |||
50 | series->append(set0); |
|
49 | series->append(set0); | |
51 | series->append(set1); |
|
50 | series->append(set1); | |
52 | series->append(set2); |
|
51 | series->append(set2); | |
53 | series->append(set3); |
|
52 | series->append(set3); | |
54 | series->append(set4); |
|
|||
55 | //![2] |
|
53 | //![2] | |
56 |
|
54 | |||
57 | //![3] |
|
55 | //![3] | |
58 | QChart* chart = new QChart(); |
|
56 | QChart* chart = new QChart(); | |
59 | chart->addSeries(series); |
|
57 | chart->addSeries(series); | |
60 | chart->setTitle("Simple barchart example"); |
|
58 | chart->setTitle("Simple barchart example"); | |
61 | //![3] |
|
59 | //![3] | |
62 |
|
60 | |||
63 | //![4] |
|
61 | //![4] | |
64 | chart->legend()->setVisible(true); |
|
62 | chart->legend()->setVisible(true); | |
65 | chart->legend()->setAlignment(Qt::AlignBottom); |
|
63 | chart->legend()->setAlignment(Qt::AlignBottom); | |
66 | chart->axisY()->setNiceNumbersEnabled(true); |
|
64 | chart->axisY()->setNiceNumbersEnabled(true); | |
67 | //![4] |
|
65 | //![4] | |
68 |
|
66 | |||
69 | //![5] |
|
67 | //![5] | |
70 | QChartView* chartView = new QChartView(chart); |
|
68 | QChartView* chartView = new QChartView(chart); | |
71 | chartView->setRenderHint(QPainter::Antialiasing); |
|
69 | chartView->setRenderHint(QPainter::Antialiasing); | |
72 | //![5] |
|
70 | //![5] | |
73 |
|
71 | |||
74 | //![6] |
|
72 | //![6] | |
75 | QMainWindow window; |
|
73 | QMainWindow window; | |
76 | window.setCentralWidget(chartView); |
|
74 | window.setCentralWidget(chartView); | |
77 | window.resize(400, 300); |
|
75 | window.resize(400, 300); | |
78 | window.show(); |
|
76 | window.show(); | |
79 | //![6] |
|
77 | //![6] | |
80 |
|
78 | |||
81 | return a.exec(); |
|
79 | return a.exec(); | |
82 | } |
|
80 | } |
General Comments 0
You need to be logged in to leave comments.
Login now