##// END OF EJS Templates
Simple to examples
sauimone -
r1623:484828e48d5e
parent child
Show More
@@ -1,92 +1,92
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 <QBarCategoriesAxis>
28 28
29 29 QTCOMMERCIALCHART_USE_NAMESPACE
30 30
31 31 int main(int argc, char *argv[])
32 32 {
33 33 QApplication a(argc, argv);
34 34
35 35 //![1]
36 36 QBarSet *set0 = new QBarSet("Jane");
37 37 QBarSet *set1 = new QBarSet("John");
38 38 QBarSet *set2 = new QBarSet("Axel");
39 39 QBarSet *set3 = new QBarSet("Mary");
40 40 QBarSet *set4 = new QBarSet("Samantha");
41 41
42 42 *set0 << 1 << 2 << 3 << 4 << 5 << 6;
43 43 *set1 << 5 << 0 << 0 << 4 << 0 << 7;
44 44 *set2 << 3 << 5 << 8 << 13 << 8 << 5;
45 45 *set3 << 5 << 6 << 7 << 3 << 4 << 5;
46 46 *set4 << 9 << 7 << 5 << 3 << 1 << 2;
47 47 //![1]
48 48
49 49 //![2]
50 50 QBarSeries* series = new QBarSeries();
51 51 series->append(set0);
52 52 series->append(set1);
53 53 series->append(set2);
54 54 series->append(set3);
55 55 series->append(set4);
56 56
57 57 //![2]
58 58
59 59 //![3]
60 60 QChart* chart = new QChart();
61 61 chart->addSeries(series);
62 chart->setTitle("Barchart example");
62 chart->setTitle("Simple barchart example");
63 63 chart->createDefaultAxes();
64 64 //![3]
65 65
66 66 //![4]
67 67 QStringList categories;
68 68 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
69 69 QBarCategoriesAxis* axis = new QBarCategoriesAxis();
70 70 axis->append(categories);
71 71 chart->setAxisX(axis,series);
72 72 //![4]
73 73
74 74 //![5]
75 75 chart->legend()->setVisible(true);
76 76 chart->legend()->setAlignment(Qt::AlignBottom);
77 77 //![5]
78 78
79 79 //![6]
80 80 QChartView* chartView = new QChartView(chart);
81 81 chartView->setRenderHint(QPainter::Antialiasing);
82 82 //![6]
83 83
84 84 //![7]
85 85 QMainWindow window;
86 86 window.setCentralWidget(chartView);
87 87 window.resize(400, 300);
88 88 window.show();
89 89 //![7]
90 90
91 91 return a.exec();
92 92 }
@@ -1,92 +1,92
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 <QPercentBarSeries>
25 25 #include <QBarSet>
26 26 #include <QLegend>
27 27 #include <QBarCategoriesAxis>
28 28
29 29 QTCOMMERCIALCHART_USE_NAMESPACE
30 30
31 31 int main(int argc, char *argv[])
32 32 {
33 33 QApplication a(argc, argv);
34 34
35 35 //![1]
36 36 QBarSet *set0 = new QBarSet("Jane");
37 37 QBarSet *set1 = new QBarSet("John");
38 38 QBarSet *set2 = new QBarSet("Axel");
39 39 QBarSet *set3 = new QBarSet("Mary");
40 40 QBarSet *set4 = new QBarSet("Samantha");
41 41
42 42 *set0 << 1 << 2 << 3 << 4 << 5 << 6;
43 43 *set1 << 5 << 0 << 0 << 4 << 0 << 7;
44 44 *set2 << 3 << 5 << 8 << 13 << 8 << 5;
45 45 *set3 << 5 << 6 << 7 << 3 << 4 << 5;
46 46 *set4 << 9 << 7 << 5 << 3 << 1 << 2;
47 47 //![1]
48 48
49 49 //![2]
50 50 QPercentBarSeries* series = new QPercentBarSeries();
51 51 series->append(set0);
52 52 series->append(set1);
53 53 series->append(set2);
54 54 series->append(set3);
55 55 series->append(set4);
56 56 //![2]
57 57
58 58 //![3]
59 59 QChart* chart = new QChart();
60 60 chart->addSeries(series);
61 chart->setTitle("Percentbarchart example");
61 chart->setTitle("Simple percentbarchart example");
62 62 //![3]
63 63
64 64 //![4]
65 65 QStringList categories;
66 66 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
67 67 QBarCategoriesAxis* axis = new QBarCategoriesAxis();
68 68 axis->append(categories);
69 69 chart->createDefaultAxes();
70 70 chart->setAxisX(axis,series);
71 71 //![4]
72 72
73 73 //![5]
74 74 chart->legend()->setVisible(true);
75 75 chart->legend()->setAlignment(Qt::AlignBottom);
76 76 //![5]
77 77
78 78 //![6]
79 79 QChartView* chartView = new QChartView(chart);
80 80 chartView->setRenderHint(QPainter::Antialiasing);
81 81 //![6]
82 82
83 83 //![7]
84 84 QMainWindow window;
85 85 window.setCentralWidget(chartView);
86 86 window.resize(400, 300);
87 87 window.show();
88 88 //![7]
89 89
90 90 return a.exec();
91 91 }
92 92
@@ -1,92 +1,92
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 <QStackedBarSeries>
25 25 #include <QBarSet>
26 26 #include <QLegend>
27 27 #include <QBarCategoriesAxis>
28 28
29 29 QTCOMMERCIALCHART_USE_NAMESPACE
30 30
31 31 int main(int argc, char *argv[])
32 32 {
33 33 QApplication a(argc, argv);
34 34
35 35 //![1]
36 36 QBarSet *set0 = new QBarSet("Jane");
37 37 QBarSet *set1 = new QBarSet("John");
38 38 QBarSet *set2 = new QBarSet("Axel");
39 39 QBarSet *set3 = new QBarSet("Mary");
40 40 QBarSet *set4 = new QBarSet("Samantha");
41 41
42 42 *set0 << 1 << 2 << 3 << 4 << 5 << 6;
43 43 *set1 << 5 << 0 << 0 << 4 << 0 << 7;
44 44 *set2 << 3 << 5 << 8 << 13 << 8 << 5;
45 45 *set3 << 5 << 6 << 7 << 3 << 4 << 5;
46 46 *set4 << 9 << 7 << 5 << 3 << 1 << 2;
47 47 //![1]
48 48
49 49 //![2]
50 50 QStackedBarSeries* series = new QStackedBarSeries();
51 51 series->append(set0);
52 52 series->append(set1);
53 53 series->append(set2);
54 54 series->append(set3);
55 55 series->append(set4);
56 56 //![2]
57 57
58 58 //![3]
59 59 QChart* chart = new QChart();
60 60 chart->addSeries(series);
61 chart->setTitle("Stackedbarchart example");
61 chart->setTitle("Simple stackedbarchart example");
62 62 chart->createDefaultAxes();
63 63 //![3]
64 64
65 65 //![4]
66 66 QStringList categories;
67 67 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
68 68 QBarCategoriesAxis* axis = new QBarCategoriesAxis();
69 69 axis->append(categories);
70 70 chart->setAxisX(axis,series);
71 71 //![4]
72 72
73 73 //![5]
74 74 chart->legend()->setVisible(true);
75 75 chart->legend()->setAlignment(Qt::AlignBottom);
76 76 //![5]
77 77
78 78 //![6]
79 79 QChartView* chartView = new QChartView(chart);
80 80 chartView->setRenderHint(QPainter::Antialiasing);
81 81 //![6]
82 82
83 83 //![7]
84 84 QMainWindow window;
85 85 window.setCentralWidget(chartView);
86 86 window.resize(400, 300);
87 87 window.show();
88 88 //![7]
89 89
90 90 return a.exec();
91 91 }
92 92
General Comments 0
You need to be logged in to leave comments. Login now