@@ -1,79 +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 | #include <QCategoriesAxis> | |
|
27 | 28 | |
|
28 | 29 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 30 | |
|
30 | 31 | int main(int argc, char *argv[]) |
|
31 | 32 | { |
|
32 | 33 | QApplication a(argc, argv); |
|
33 | 34 | |
|
34 | 35 | //![1] |
|
35 | 36 | QBarSet *set0 = new QBarSet("Jane"); |
|
36 | 37 | QBarSet *set1 = new QBarSet("John"); |
|
37 | 38 | QBarSet *set2 = new QBarSet("Axel"); |
|
38 | 39 | QBarSet *set3 = new QBarSet("Mary"); |
|
40 | QBarSet *set4 = new QBarSet("Samantha"); | |
|
39 | 41 | |
|
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); | |
|
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); | |
|
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); | |
|
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); | |
|
42 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
|
43 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
|
44 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
|
45 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
|
46 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
|
44 | 47 | //![1] |
|
45 | 48 | |
|
46 | 49 | //![2] |
|
47 | 50 | QBarSeries* series = new QBarSeries(); |
|
48 | series->setBarWidth(0.2); | |
|
49 | 51 | series->append(set0); |
|
50 | 52 | series->append(set1); |
|
51 | 53 | series->append(set2); |
|
52 | 54 | series->append(set3); |
|
55 | series->append(set4); | |
|
56 | ||
|
53 | 57 | //![2] |
|
54 | 58 | |
|
55 | 59 | //![3] |
|
56 | 60 | QChart* chart = new QChart(); |
|
57 | 61 | chart->addSeries(series); |
|
58 | 62 | chart->setTitle("Barchart example"); |
|
63 | chart->createDefaultAxes(); | |
|
59 | 64 | //![3] |
|
60 | 65 | |
|
61 | 66 | //![4] |
|
62 | chart->legend()->setVisible(true); | |
|
63 | chart->legend()->setAlignment(Qt::AlignBottom); | |
|
67 | QStringList categories; | |
|
68 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
|
69 | QCategoriesAxis* axis = new QCategoriesAxis(); | |
|
70 | axis->append(categories); | |
|
71 | chart->setAxisX(axis,series); | |
|
64 | 72 | //![4] |
|
65 | 73 | |
|
66 | 74 | //![5] |
|
67 | QChartView* chartView = new QChartView(chart); | |
|
68 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
75 | chart->legend()->setVisible(true); | |
|
76 | chart->legend()->setAlignment(Qt::AlignBottom); | |
|
69 | 77 | //![5] |
|
70 | 78 | |
|
71 | 79 | //![6] |
|
80 | QChartView* chartView = new QChartView(chart); | |
|
81 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
82 | //![6] | |
|
83 | ||
|
84 | //![7] | |
|
72 | 85 | QMainWindow window; |
|
73 | 86 | window.setCentralWidget(chartView); |
|
74 | 87 | window.resize(400, 300); |
|
75 | 88 | window.show(); |
|
76 |
//![ |
|
|
89 | //![7] | |
|
77 | 90 | |
|
78 | 91 | return a.exec(); |
|
79 | 92 | } |
@@ -1,25 +1,25 | |||
|
1 | 1 | CURRENTLY_BUILDING_COMPONENTS = "examples" |
|
2 | 2 | !include( ../config.pri ) { |
|
3 | 3 | error( "Couldn't find the config.pri file!" ) |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | TEMPLATE = subdirs |
|
7 | 7 | SUBDIRS += \ |
|
8 | 8 | areachart \ |
|
9 | 9 | #customchart \ |
|
10 | 10 | linechart \ |
|
11 | 11 | percentbarchart \ |
|
12 | 12 | piechart \ |
|
13 | 13 | piechartdrilldown \ |
|
14 | 14 | presenterchart \ |
|
15 | 15 | scatterchart \ |
|
16 | 16 | scatterinteractions \ |
|
17 | 17 | splinechart \ |
|
18 | 18 | stackedbarchart \ |
|
19 | 19 | stackedbarchartdrilldown \ |
|
20 | 20 | zoomlinechart \ |
|
21 | 21 | modeldata \ |
|
22 |
|
|
|
22 | barchart \ | |
|
23 | 23 | legend \ |
|
24 | 24 | barmodelmapper \ |
|
25 | 25 | qmlpiechart |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now