@@ -0,0 +1,6 | |||||
|
1 | !include( ../examples.pri ) { | |||
|
2 | error( "Couldn't find the examples.pri file!" ) | |||
|
3 | } | |||
|
4 | ||||
|
5 | TARGET = lineandbar | |||
|
6 | SOURCES += main.cpp |
@@ -0,0 +1,111 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include <QApplication> | |||
|
22 | #include <QMainWindow> | |||
|
23 | #include <QChartView> | |||
|
24 | #include <QBarSeries> | |||
|
25 | #include <QBarSet> | |||
|
26 | #include <QLineSeries> | |||
|
27 | #include <QLegend> | |||
|
28 | #include <QBarCategoriesAxis> | |||
|
29 | #include <QValuesAxis> | |||
|
30 | ||||
|
31 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
32 | ||||
|
33 | int main(int argc, char *argv[]) | |||
|
34 | { | |||
|
35 | QApplication a(argc, argv); | |||
|
36 | ||||
|
37 | //![1] | |||
|
38 | QBarSet *set0 = new QBarSet("Jane"); | |||
|
39 | QBarSet *set1 = new QBarSet("John"); | |||
|
40 | QBarSet *set2 = new QBarSet("Axel"); | |||
|
41 | QBarSet *set3 = new QBarSet("Mary"); | |||
|
42 | QBarSet *set4 = new QBarSet("Samantha"); | |||
|
43 | ||||
|
44 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |||
|
45 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |||
|
46 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |||
|
47 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |||
|
48 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |||
|
49 | //![1] | |||
|
50 | ||||
|
51 | //![2] | |||
|
52 | QBarSeries* barseries = new QBarSeries(); | |||
|
53 | barseries->append(set0); | |||
|
54 | barseries->append(set1); | |||
|
55 | barseries->append(set2); | |||
|
56 | barseries->append(set3); | |||
|
57 | barseries->append(set4); | |||
|
58 | //![2] | |||
|
59 | ||||
|
60 | //![8] | |||
|
61 | QLineSeries* lineseries = new QLineSeries(); | |||
|
62 | ||||
|
63 | lineseries->append(QPoint(0,4)); | |||
|
64 | lineseries->append(QPoint(1,15)); | |||
|
65 | lineseries->append(QPoint(2,20)); | |||
|
66 | lineseries->append(QPoint(3,4)); | |||
|
67 | lineseries->append(QPoint(4,12)); | |||
|
68 | lineseries->append(QPoint(5,17)); | |||
|
69 | //![8] | |||
|
70 | ||||
|
71 | //![3] | |||
|
72 | QChart* chart = new QChart(); | |||
|
73 | chart->addSeries(barseries); | |||
|
74 | chart->addSeries(lineseries); | |||
|
75 | chart->setTitle("Line and barchart example"); | |||
|
76 | //![3] | |||
|
77 | ||||
|
78 | //![4] | |||
|
79 | QStringList categories; | |||
|
80 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |||
|
81 | QBarCategoriesAxis* axisX = new QBarCategoriesAxis(); | |||
|
82 | axisX->append(categories); | |||
|
83 | chart->setAxisX(axisX,lineseries); | |||
|
84 | chart->setAxisX(axisX,barseries); | |||
|
85 | axisX->setRange(QString("Jan"),QString("Jun")); | |||
|
86 | ||||
|
87 | QValuesAxis* axisY = new QValuesAxis(); | |||
|
88 | chart->setAxisY(axisY,lineseries); | |||
|
89 | chart->setAxisY(axisY,barseries); | |||
|
90 | axisY->setRange(0,20); | |||
|
91 | //![4] | |||
|
92 | ||||
|
93 | //![5] | |||
|
94 | chart->legend()->setVisible(true); | |||
|
95 | chart->legend()->setAlignment(Qt::AlignBottom); | |||
|
96 | //![5] | |||
|
97 | ||||
|
98 | //![6] | |||
|
99 | QChartView* chartView = new QChartView(chart); | |||
|
100 | chartView->setRenderHint(QPainter::Antialiasing); | |||
|
101 | //![6] | |||
|
102 | ||||
|
103 | //![7] | |||
|
104 | QMainWindow window; | |||
|
105 | window.setCentralWidget(chartView); | |||
|
106 | window.resize(400, 300); | |||
|
107 | window.show(); | |||
|
108 | //![7] | |||
|
109 | ||||
|
110 | return a.exec(); | |||
|
111 | } |
@@ -1,25 +1,26 | |||||
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" |
|
1 | CURRENTLY_BUILDING_COMPONENTS = "examples" | |
2 | !include( ../config.pri ) { |
|
2 | !include( ../config.pri ) { | |
3 | error( "Couldn't find the config.pri file!" ) |
|
3 | error( "Couldn't find the config.pri file!" ) | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | TEMPLATE = subdirs |
|
6 | TEMPLATE = subdirs | |
7 | SUBDIRS += \ |
|
7 | SUBDIRS += \ | |
8 | areachart \ |
|
8 | areachart \ | |
9 | customchart \ |
|
9 | customchart \ | |
10 | linechart \ |
|
10 | linechart \ | |
11 | percentbarchart \ |
|
11 | percentbarchart \ | |
12 | piechart \ |
|
12 | piechart \ | |
13 | piechartdrilldown \ |
|
13 | piechartdrilldown \ | |
14 | presenterchart \ |
|
14 | presenterchart \ | |
15 | scatterchart \ |
|
15 | scatterchart \ | |
16 | scatterinteractions \ |
|
16 | scatterinteractions \ | |
17 | splinechart \ |
|
17 | splinechart \ | |
18 | stackedbarchart \ |
|
18 | stackedbarchart \ | |
19 | stackedbarchartdrilldown \ |
|
19 | stackedbarchartdrilldown \ | |
20 | zoomlinechart \ |
|
20 | zoomlinechart \ | |
21 | modeldata \ |
|
21 | modeldata \ | |
22 | barchart \ |
|
22 | barchart \ | |
23 | legend \ |
|
23 | legend \ | |
24 | barmodelmapper \ |
|
24 | barmodelmapper \ | |
25 | qmlpiechart |
|
25 | qmlpiechart \ | |
|
26 | lineandbar |
General Comments 0
You need to be logged in to leave comments.
Login now