@@ -1,57 +1,94 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 | 44 | #include <QChartView> |
|
4 | 45 | #include <QLineSeries> |
|
5 | 46 | #include <QAreaSeries> |
|
6 | #include <cmath> | |
|
7 | 47 | |
|
8 | 48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | 49 | |
|
10 | 50 | int main(int argc, char *argv[]) |
|
11 | 51 | { |
|
12 | 52 | QApplication a(argc, argv); |
|
13 | ||
|
14 | 53 | //![1] |
|
15 | ||
|
16 | 54 | QLineSeries* series0 = new QLineSeries(); |
|
17 | 55 | QLineSeries* series1 = new QLineSeries(); |
|
18 | ||
|
19 | 56 | //![1] |
|
20 | 57 | |
|
21 | 58 | //![2] |
|
22 |
*series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12,6) |
|
|
23 | *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12,3) << QPointF(16,4) << QPointF(18,3); | |
|
59 | *series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12, 6) | |
|
60 | << QPointF(16, 7) << QPointF(18, 5); | |
|
61 | *series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12, 3) | |
|
62 | << QPointF(16, 4) << QPointF(18, 3); | |
|
24 | 63 | //![2] |
|
25 | 64 | //![3] |
|
26 | ||
|
27 | QAreaSeries* series = new QAreaSeries(series0,series1); | |
|
65 | QAreaSeries* series = new QAreaSeries(series0, series1); | |
|
28 | 66 | QPen pen(0x059605); |
|
29 | 67 | pen.setWidth(3); |
|
30 | 68 | series->setPen(pen); |
|
31 | 69 | |
|
32 | 70 | QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1)); |
|
33 | gradient.setColorAt(0.0,0x3cc63c); | |
|
71 | gradient.setColorAt(0.0, 0x3cc63c); | |
|
34 | 72 | gradient.setColorAt(1.0, 0x26f626); |
|
35 | 73 | gradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
36 | 74 | series->setBrush(gradient); |
|
37 | ||
|
38 | 75 | //![3] |
|
39 | 76 | //![4] |
|
40 | QMainWindow window; | |
|
41 | QChartView* chartView = new QChartView(&window); | |
|
42 | ||
|
43 | chartView->setChartTitle("Simple area chart example"); | |
|
44 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
45 | ||
|
46 | chartView->addSeries(series); | |
|
47 | chartView->axisX()->setRange(0,20); | |
|
48 | chartView->axisY()->setRange(0,10); | |
|
77 | QChart* chart = new QChart(); | |
|
78 | chart->addSeries(series); | |
|
79 | chart->setTitle("Simple areachart example"); | |
|
80 | chart->axisX()->setRange(0, 20); | |
|
81 | chart->axisY()->setRange(0, 10); | |
|
49 | 82 | //![4] |
|
50 | 83 | //![5] |
|
84 | QChartView* chartView = new QChartView(chart); | |
|
85 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
86 | //![5] | |
|
87 | //![6] | |
|
88 | QMainWindow window; | |
|
51 | 89 | window.setCentralWidget(chartView); |
|
52 | 90 | window.resize(400, 300); |
|
53 | 91 | window.show(); |
|
54 |
//![ |
|
|
55 | ||
|
92 | //![6] | |
|
56 | 93 | return a.exec(); |
|
57 | 94 | } |
@@ -3,8 +3,5 | |||
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TARGET = barchart |
|
6 |
SOURCES += main.cpp |
|
|
7 | chartwidget.cpp | |
|
8 | HEADERS += \ | |
|
9 | chartwidget.h | |
|
6 | SOURCES += main.cpp | |
|
10 | 7 |
@@ -1,27 +1,60 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 |
#include < |
|
|
4 |
#include < |
|
|
5 |
#include < |
|
|
6 | #include <qchartaxis.h> | |
|
7 | #include <QStringList> | |
|
44 | #include <QChartView> | |
|
45 | #include <QBarSeries> | |
|
46 | #include <QBarSet> | |
|
8 | 47 | |
|
9 | 48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
10 | 49 | |
|
11 | 50 | int main(int argc, char *argv[]) |
|
12 | 51 | { |
|
13 | 52 | QApplication a(argc, argv); |
|
14 | QMainWindow window; | |
|
15 | ||
|
16 | //! [1] | |
|
17 | // Define categories | |
|
18 | QStringList categories; | |
|
53 | //![1] | |
|
54 | QBarCategories categories; | |
|
19 | 55 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
20 |
|
|
|
21 | ||
|
22 | //! [2] | |
|
23 | // Create some test sets for chat | |
|
24 | ||
|
56 | //![1] | |
|
57 | //![2] | |
|
25 | 58 | QBarSet *set0 = new QBarSet("Bub"); |
|
26 | 59 | QBarSet *set1 = new QBarSet("Bob"); |
|
27 | 60 | QBarSet *set2 = new QBarSet("Guybrush"); |
@@ -33,48 +66,29 int main(int argc, char *argv[]) | |||
|
33 | 66 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
34 | 67 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
35 | 68 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
36 |
|
|
|
37 | ||
|
38 | //! [3] | |
|
39 | // Create series and add sets to it | |
|
40 | QBarSeries* series= new QBarSeries(categories); | |
|
41 | ||
|
69 | //![2] | |
|
70 | //![3] | |
|
71 | QBarSeries* series = new QBarSeries(categories); | |
|
42 | 72 | series->addBarSet(set0); |
|
43 | 73 | series->addBarSet(set1); |
|
44 | 74 | series->addBarSet(set2); |
|
45 | 75 | series->addBarSet(set3); |
|
46 | 76 | series->addBarSet(set4); |
|
47 |
|
|
|
48 | ||
|
49 | //! [4] | |
|
50 | // Enable tooltip | |
|
51 | series->setToolTipEnabled(); | |
|
52 | ||
|
53 | // Connect clicked signal of set to toggle floating values of set. | |
|
54 | QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues())); | |
|
55 | QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues())); | |
|
56 | QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues())); | |
|
57 | QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues())); | |
|
58 | QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues())); | |
|
59 | //! [4] | |
|
60 | ||
|
61 | //! [5] | |
|
62 | // Create view for chart and add series to it. Apply theme. | |
|
63 | ||
|
64 | QChartView* chartView = new QChartView(&window); | |
|
65 | chartView->addSeries(series); | |
|
66 | chartView->setChartTitle("simple barchart"); | |
|
67 | chartView->setChartTheme(QChart::ChartThemeIcy); | |
|
68 | //! [5] | |
|
69 | ||
|
70 | //! [6] | |
|
71 | chartView->axisX()->setGridLineVisible(false); | |
|
72 | //! [6] | |
|
73 | ||
|
77 | //![3] | |
|
78 | //![4] | |
|
79 | QChart* chart = new QChart(); | |
|
80 | chart->addSeries(series); | |
|
81 | chart->setTitle("Simple barchart example"); | |
|
82 | //![4] | |
|
83 | //![5] | |
|
84 | QChartView* chartView = new QChartView(chart); | |
|
85 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
86 | //![5] | |
|
87 | //![6] | |
|
88 | QMainWindow window; | |
|
74 | 89 | window.setCentralWidget(chartView); |
|
75 | 90 | window.resize(400, 300); |
|
76 | 91 | window.show(); |
|
77 | ||
|
92 | //![6] | |
|
78 | 93 | return a.exec(); |
|
79 | 94 | } |
|
80 |
@@ -1,55 +1,95 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 |
#include < |
|
|
4 |
#include < |
|
|
5 | #include <qchart.h> | |
|
6 | #include <cmath> | |
|
44 | #include <QChartView> | |
|
45 | #include <QLineSeries> | |
|
7 | 46 | |
|
8 | 47 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | 48 | |
|
10 | #define PI 3.14159265358979 | |
|
11 | ||
|
12 | 49 | int main(int argc, char *argv[]) |
|
13 | 50 | { |
|
14 | 51 | QApplication a(argc, argv); |
|
15 | 52 | |
|
16 | QMainWindow window; | |
|
17 | ||
|
18 | QLineSeries* series0 = new QLineSeries(); | |
|
53 | //![1] | |
|
54 | QLineSeries* series = new QLineSeries(); | |
|
19 | 55 | QPen blue(Qt::blue); |
|
20 | 56 | blue.setWidth(3); |
|
21 |
series |
|
|
22 | QLineSeries* series1 = new QLineSeries(); | |
|
23 | QPen red(Qt::red); | |
|
24 | red.setWidth(3); | |
|
25 | series1->setPen(red); | |
|
26 | ||
|
27 | int numPoints = 100; | |
|
28 | ||
|
29 | for (int x = 0; x <= numPoints; ++x) { | |
|
30 | series0->add(x, fabs(sin(PI/50*x)*100)); | |
|
31 | series1->add(x, fabs(cos(PI/50*x)*100)); | |
|
32 | } | |
|
33 | ||
|
34 | QChartView* chartView = new QChartView(&window); | |
|
35 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
36 | ||
|
57 | series->setPen(blue); | |
|
58 | //![1] | |
|
59 | //![2] | |
|
60 | *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5); | |
|
61 | //![2] | |
|
62 | //![3] | |
|
63 | QChart* chart = new QChart(); | |
|
64 | chart->addSeries(series); | |
|
65 | chart->setTitle("Custom colors example"); | |
|
66 | //![3] | |
|
67 | //![4] | |
|
37 | 68 | QFont font; |
|
38 | 69 | font.setPixelSize(18); |
|
39 |
chart |
|
|
40 | chartView->setChartTitle("Custom color line chart example"); | |
|
41 | chartView->addSeries(series0); | |
|
42 | chartView->addSeries(series1); | |
|
70 | chart->setTitleFont(font); | |
|
71 | chart->setTitleBrush(Qt::red); | |
|
43 | 72 | |
|
44 | 73 | QLinearGradient backgroundGradient; |
|
45 |
backgroundGradient.setColorAt(0.0, Qt:: |
|
|
46 |
backgroundGradient.setColorAt(1.0, Qt:: |
|
|
74 | backgroundGradient.setColorAt(0.0, Qt::lightGray); | |
|
75 | backgroundGradient.setColorAt(1.0, Qt::white); | |
|
47 | 76 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
48 |
chart |
|
|
77 | chart->setBackgroundBrush(backgroundGradient); | |
|
49 | 78 | |
|
79 | QPen black(Qt::black); | |
|
80 | chart->axisX()->setGridLinePen(black); | |
|
81 | chart->axisX()->setAxisPen(black); | |
|
82 | chart->axisY()->setGridLinePen(black); | |
|
83 | chart->axisY()->setAxisPen(black); | |
|
84 | //![4] | |
|
85 | //![5] | |
|
86 | QChartView* chartView = new QChartView(chart); | |
|
87 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
88 | //![5] | |
|
89 | QMainWindow window; | |
|
50 | 90 | window.setCentralWidget(chartView); |
|
51 | 91 | window.resize(400, 300); |
|
52 | 92 | window.show(); |
|
53 | ||
|
93 | //![5] | |
|
54 | 94 | return a.exec(); |
|
55 | 95 | } |
@@ -1,23 +1,32 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 |
SUBDIRS += |
|
|
3 |
|
|
|
4 |
|
|
|
2 | SUBDIRS += \ | |
|
3 | areachart \ | |
|
4 | #axischart \ | |
|
5 | 5 | barchart \ |
|
6 |
|
|
|
6 | #chartview \ | |
|
7 | colorlinechart \ | |
|
8 | #customcolors \ | |
|
9 | #dynamiclinechart \ | |
|
10 | #ekgchart \ | |
|
11 | #gdpbarchart \ | |
|
12 | linechart \ | |
|
13 | #multichart \ | |
|
7 | 14 | percentbarchart \ |
|
8 | scatterchart \ | |
|
9 | 15 | piechart \ |
|
10 | piechartdrilldown \ | |
|
11 |
|
|
|
12 |
|
|
|
13 | multichart \ | |
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 | scatterinteractions \ | |
|
18 |
|
|
|
19 |
|
|
|
20 | stackedbarchartdrilldown \ | |
|
21 | customcolors \ | |
|
22 | tablemodelchart \ | |
|
23 |
|
|
|
16 | #piechartdrilldown \ | |
|
17 | #presenterchart \ | |
|
18 | scatterchart \ | |
|
19 | #scatterinteractions \ | |
|
20 | #splinechart \ | |
|
21 | stackedbarchart \ | |
|
22 | #stackedbarchartdrilldown \ | |
|
23 | #tablemodelchart \ | |
|
24 | zoomlinechart | |
|
25 | ||
|
26 | ||
|
27 | ||
|
28 | ||
|
29 | ||
|
30 | ||
|
31 | ||
|
32 |
@@ -1,15 +1,54 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 | 44 | #include <QChartView> |
|
4 | 45 | #include <QLineSeries> |
|
5 | #include <cmath> | |
|
6 | 46 | |
|
7 | 47 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | 48 | |
|
9 | 49 | int main(int argc, char *argv[]) |
|
10 | 50 | { |
|
11 | 51 | QApplication a(argc, argv); |
|
12 | ||
|
13 | 52 | //![1] |
|
14 | 53 | QLineSeries* series0 = new QLineSeries(); |
|
15 | 54 | QPen blue(Qt::blue); |
@@ -27,25 +66,26 int main(int argc, char *argv[]) | |||
|
27 | 66 | series0->add(2, 4); |
|
28 | 67 | series0->add(3, 8); |
|
29 | 68 | series0->add(7, 4); |
|
30 | series0->add(10,5); | |
|
69 | series0->add(10, 5); | |
|
31 | 70 | |
|
32 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10,2); | |
|
71 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); | |
|
33 | 72 | //![2] |
|
34 | 73 | //![3] |
|
35 | QMainWindow window; | |
|
36 | QChartView* chartView = new QChartView(&window); | |
|
37 | ||
|
38 | chartView->setChartTitle("Simple line chart"); | |
|
39 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
74 | QChart* chart = new QChart(); | |
|
40 | 75 | |
|
41 |
chart |
|
|
42 |
chart |
|
|
76 | chart->addSeries(series0); | |
|
77 | chart->addSeries(series1); | |
|
78 | chart->setTitle("Simple line chart example"); | |
|
43 | 79 | //![3] |
|
44 | 80 | //![4] |
|
81 | QChartView* chartView = new QChartView(chart); | |
|
82 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
83 | //![4] | |
|
84 | //![5] | |
|
85 | QMainWindow window; | |
|
45 | 86 | window.setCentralWidget(chartView); |
|
46 | 87 | window.resize(400, 300); |
|
47 | 88 | window.show(); |
|
48 |
//![ |
|
|
49 | ||
|
89 | //![5] | |
|
50 | 90 | return a.exec(); |
|
51 | 91 | } |
@@ -1,27 +1,60 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 |
#include <Q |
|
|
4 |
#include < |
|
|
5 |
#include < |
|
|
6 | #include <qbarset.h> | |
|
7 | #include <qchartaxis.h> | |
|
8 | #include <QStringList> | |
|
44 | #include <QChartView> | |
|
45 | #include <QPercentBarSeries> | |
|
46 | #include <QBarSet> | |
|
9 | 47 | |
|
10 | 48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
11 | 49 | |
|
12 | 50 | int main(int argc, char *argv[]) |
|
13 | 51 | { |
|
14 | 52 | QApplication a(argc, argv); |
|
15 | QMainWindow window; | |
|
16 | ||
|
17 | //! [1] | |
|
18 | // Define categories | |
|
19 | QStringList categories; | |
|
53 | //![1] | |
|
54 | QBarCategories categories; | |
|
20 | 55 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
21 |
|
|
|
22 | ||
|
23 | //! [2] | |
|
24 | // Create some test sets for chat | |
|
56 | //![1] | |
|
57 | //![2] | |
|
25 | 58 | QBarSet *set0 = new QBarSet("Bub"); |
|
26 | 59 | QBarSet *set1 = new QBarSet("Bob"); |
|
27 | 60 | QBarSet *set2 = new QBarSet("Guybrush"); |
@@ -33,51 +66,30 int main(int argc, char *argv[]) | |||
|
33 | 66 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
34 | 67 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
35 | 68 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
36 |
|
|
|
37 | ||
|
38 | //! [3] | |
|
39 | // Create series and add sets to it | |
|
69 | //![2] | |
|
70 | //![3] | |
|
40 | 71 | QPercentBarSeries* series = new QPercentBarSeries(categories); |
|
41 | ||
|
42 | 72 | series->addBarSet(set0); |
|
43 | 73 | series->addBarSet(set1); |
|
44 | 74 | series->addBarSet(set2); |
|
45 | 75 | series->addBarSet(set3); |
|
46 | 76 | series->addBarSet(set4); |
|
47 |
|
|
|
48 | ||
|
49 | //! [4] | |
|
50 | // Enable tooltip | |
|
51 | series->setToolTipEnabled(); | |
|
52 | ||
|
53 | // Connect clicked signal of set to toggle floating values of set. | |
|
54 | // Note that we leave QBarset "Zak" unconnected here, so clicking on it doesn't toggle values. | |
|
55 | QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues())); | |
|
56 | QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues())); | |
|
57 | QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues())); | |
|
58 | QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues())); | |
|
59 | QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues())); | |
|
60 | //! [4] | |
|
61 | ||
|
62 | //! [5] | |
|
63 | // Create view for chart and add series to it. Apply theme. | |
|
64 | ||
|
65 | QChartView* chartView = new QChartView(&window); | |
|
66 | chartView->addSeries(series); | |
|
67 | chartView->setChartTitle("simple percent barchart"); | |
|
68 | chartView->setChartTheme(QChart::ChartThemeIcy); | |
|
69 | //! [5] | |
|
70 | ||
|
71 | //! [6] | |
|
72 | //chartView->axisX()->setAxisVisible(false); | |
|
73 | chartView->axisX()->setGridLineVisible(false); | |
|
74 | chartView->axisX()->setLabelsVisible(false); | |
|
75 | //! [6] | |
|
76 | ||
|
77 | //! [3] | |
|
78 | //![4] | |
|
79 | QChart* chart = new QChart(); | |
|
80 | chart->addSeries(series); | |
|
81 | chart->setTitle("Simple precentbarchart example"); | |
|
82 | //![4] | |
|
83 | //![5] | |
|
84 | QChartView* chartView = new QChartView(chart); | |
|
85 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
86 | //![5] | |
|
87 | //![6] | |
|
88 | QMainWindow window; | |
|
77 | 89 | window.setCentralWidget(chartView); |
|
78 | 90 | window.resize(400, 300); |
|
79 | 91 | window.show(); |
|
80 | ||
|
92 | //![6] | |
|
81 | 93 | return a.exec(); |
|
82 | 94 | } |
|
83 | 95 |
@@ -3,8 +3,5 | |||
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TARGET = percentbarchart |
|
6 |
SOURCES += main.cpp |
|
|
7 | chartwidget.cpp | |
|
8 | HEADERS += \ | |
|
9 | chartwidget.h | |
|
6 | SOURCES += main.cpp | |
|
10 | 7 |
@@ -1,9 +1,49 | |||
|
1 | #include <QtGui/QApplication> | |
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
42 | #include <QApplication> | |
|
2 | 43 | #include <QMainWindow> |
|
3 |
#include < |
|
|
4 | #include <qchartview.h> | |
|
5 |
#include < |
|
|
6 | #include <qpieslice.h> | |
|
44 | #include <QChartView> | |
|
45 | #include <QPieSeries> | |
|
46 | #include <QPieSlice> | |
|
7 | 47 | |
|
8 | 48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
9 | 49 | |
@@ -11,34 +51,36 int main(int argc, char *argv[]) | |||
|
11 | 51 | { |
|
12 | 52 | QApplication a(argc, argv); |
|
13 | 53 | |
|
14 | QMainWindow window; | |
|
15 | ||
|
16 | QChartView* chartView = new QChartView(&window); | |
|
17 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
18 | chartView->setChartTitle("Simple pie chart"); | |
|
19 | ||
|
20 | //! [1] | |
|
54 | //![1] | |
|
21 | 55 | QPieSeries *series = new QPieSeries(); |
|
22 | 56 | series->add(1, "Slice 1"); |
|
23 | 57 | series->add(2, "Slice 2"); |
|
24 | 58 | series->add(3, "Slice 3"); |
|
25 | 59 | series->add(4, "Slice 4"); |
|
26 | 60 | series->add(5, "Slice 5"); |
|
27 |
|
|
|
61 | //![1] | |
|
28 | 62 | |
|
29 |
|
|
|
63 | //![2] | |
|
30 | 64 | QPieSlice *slice = series->slices().first(); |
|
31 | 65 | slice->setExploded(); |
|
32 | 66 | slice->setLabelVisible(); |
|
33 | 67 | slice->setSlicePen(QPen(Qt::darkGreen, 2)); |
|
34 | 68 | slice->setSliceBrush(Qt::green); |
|
35 |
|
|
|
36 | ||
|
37 | chartView->addSeries(series); | |
|
38 | ||
|
69 | //![2] | |
|
70 | //![3] | |
|
71 | QChart* chart = new QChart(); | |
|
72 | chart->addSeries(series); | |
|
73 | chart->setTitle("Simple piechart example"); | |
|
74 | //![3] | |
|
75 | //![4] | |
|
76 | QChartView* chartView = new QChartView(chart); | |
|
77 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
78 | //![4] | |
|
79 | //![5] | |
|
80 | QMainWindow window; | |
|
39 | 81 | window.setCentralWidget(chartView); |
|
40 |
window.resize( |
|
|
82 | window.resize(400, 300); | |
|
41 | 83 | window.show(); |
|
42 | ||
|
84 | //![5] | |
|
43 | 85 | return a.exec(); |
|
44 | 86 | } |
@@ -1,3 +1,44 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QtGui/QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 | 44 | #include <QChartView> |
@@ -8,41 +49,50 QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
8 | 49 | int main(int argc, char *argv[]) |
|
9 | 50 | { |
|
10 | 51 | QApplication a(argc, argv); |
|
11 | ||
|
12 | //! [1] | |
|
13 | QScatterSeries *scatter = new QScatterSeries(); | |
|
14 | ||
|
15 | QBrush brush(Qt::red); | |
|
52 | //![1] | |
|
16 | 53 | QPen pen(Qt::black); |
|
17 | 54 | pen.setWidth(2); |
|
55 | QBrush blue(Qt::blue); | |
|
56 | QBrush red(Qt::red); | |
|
18 | 57 | |
|
19 | scatter->setPen(pen); | |
|
20 | scatter->setBrush(brush); | |
|
21 | scatter->setShape(QScatterSeries::MarkerShapeCircle); | |
|
22 | scatter->setSize(15.0); | |
|
23 | //! [1] | |
|
24 | ||
|
25 | //! [2] | |
|
26 | for (qreal i(0.0); i < 20; i += 0.5) { | |
|
27 | qreal x = i + (qreal) (rand() % 100) / 100.0; | |
|
28 | qreal y = i + (qreal) (rand() % 100) / 100.0; | |
|
29 | scatter->add(x, y); | |
|
30 | } | |
|
31 | *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4); | |
|
32 | //! [2] | |
|
33 | ||
|
34 | //! [3] | |
|
35 | QMainWindow window; | |
|
36 | QChartView *chartView = new QChartView(&window); | |
|
37 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
38 | chartView->setChartTitle("Simple scatter chart example"); | |
|
39 | chartView->addSeries(scatter); | |
|
40 | //! [3] | |
|
58 | QScatterSeries *series0 = new QScatterSeries(); | |
|
59 | series0->setPen(pen); | |
|
60 | series0->setBrush(blue); | |
|
61 | series0->setShape(QScatterSeries::MarkerShapeCircle); | |
|
62 | series0->setSize(15.0); | |
|
41 | 63 | |
|
42 | //! [4] | |
|
64 | QScatterSeries *series1 = new QScatterSeries(); | |
|
65 | series1->setPen(pen); | |
|
66 | series1->setBrush(red); | |
|
67 | series1->setShape(QScatterSeries::MarkerShapeCircle); | |
|
68 | series1->setSize(15.0); | |
|
69 | //![1] | |
|
70 | ||
|
71 | //![2] | |
|
72 | series0->add(0, 6); | |
|
73 | series0->add(2, 4); | |
|
74 | series0->add(3, 8); | |
|
75 | series0->add(7, 4); | |
|
76 | series0->add(10, 5); | |
|
77 | ||
|
78 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); | |
|
79 | //![2] | |
|
80 | //![3] | |
|
81 | QChart* chart = new QChart(); | |
|
82 | ||
|
83 | chart->addSeries(series0); | |
|
84 | chart->addSeries(series1); | |
|
85 | chart->setTitle("Simple scatterchart example"); | |
|
86 | //![3] | |
|
87 | //![4] | |
|
88 | QChartView* chartView = new QChartView(chart); | |
|
89 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
90 | //![4] | |
|
91 | //![5] | |
|
92 | QMainWindow window; | |
|
43 | 93 | window.setCentralWidget(chartView); |
|
44 | 94 | window.resize(400, 300); |
|
45 | 95 | window.show(); |
|
46 |
//! |
|
|
96 | //![5] | |
|
47 | 97 | return a.exec(); |
|
48 | 98 | } |
@@ -1,26 +1,60 | |||
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
1 | 42 | #include <QApplication> |
|
2 | 43 | #include <QMainWindow> |
|
3 |
#include < |
|
|
4 |
#include < |
|
|
5 |
#include < |
|
|
6 | #include <qchartaxis.h> | |
|
7 | #include <QStringList> | |
|
44 | #include <QChartView> | |
|
45 | #include <QStackedBarSeries> | |
|
46 | #include <QBarSet> | |
|
8 | 47 | |
|
9 | 48 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
10 | 49 | |
|
11 | 50 | int main(int argc, char *argv[]) |
|
12 | 51 | { |
|
13 | 52 | QApplication a(argc, argv); |
|
14 | QMainWindow window; | |
|
15 | ||
|
16 | //! [1] | |
|
17 | // Define categories | |
|
18 | QStringList categories; | |
|
53 | //![1] | |
|
54 | QBarCategories categories; | |
|
19 | 55 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
20 |
|
|
|
21 | ||
|
22 | //! [2] | |
|
23 | // Create some test sets for chat | |
|
56 | //![1] | |
|
57 | //![2] | |
|
24 | 58 | QBarSet *set0 = new QBarSet("Bub"); |
|
25 | 59 | QBarSet *set1 = new QBarSet("Bob"); |
|
26 | 60 | QBarSet *set2 = new QBarSet("Guybrush"); |
@@ -32,48 +66,30 int main(int argc, char *argv[]) | |||
|
32 | 66 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
33 | 67 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
34 | 68 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
35 |
|
|
|
36 | ||
|
37 | //! [3] | |
|
38 | // Create series and add sets to it | |
|
69 | //![2] | |
|
70 | //![3] | |
|
39 | 71 | QStackedBarSeries* series = new QStackedBarSeries(categories); |
|
40 | ||
|
41 | 72 | series->addBarSet(set0); |
|
42 | 73 | series->addBarSet(set1); |
|
43 | 74 | series->addBarSet(set2); |
|
44 | 75 | series->addBarSet(set3); |
|
45 | 76 | series->addBarSet(set4); |
|
46 |
|
|
|
47 | ||
|
48 | //! [4] | |
|
49 | // Enable tooltip | |
|
50 | series->setToolTipEnabled(); | |
|
51 | ||
|
52 | // Connect clicked signal of set to toggle floating values of set. | |
|
53 | QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues())); | |
|
54 | QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues())); | |
|
55 | QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues())); | |
|
56 | QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues())); | |
|
57 | QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues())); | |
|
58 | //! [4] | |
|
59 | ||
|
60 | //! [5] | |
|
61 | // Create view for chart and add series to it. Apply theme. | |
|
62 | ||
|
63 | QChartView* chartView = new QChartView(&window); | |
|
64 | chartView->addSeries(series); | |
|
65 | chartView->setChartTitle("simple stacked barchart"); | |
|
66 | chartView->setChartTheme(QChart::ChartThemeIcy); | |
|
67 | //! [5] | |
|
68 | ||
|
69 | //! [6] | |
|
70 | chartView->axisX()->setGridLineVisible(false); | |
|
71 | //! [6] | |
|
72 | ||
|
77 | //![3] | |
|
78 | //![4] | |
|
79 | QChart* chart = new QChart(); | |
|
80 | chart->addSeries(series); | |
|
81 | chart->setTitle("Simple stackedbarchart example"); | |
|
82 | //![4] | |
|
83 | //![5] | |
|
84 | QChartView* chartView = new QChartView(chart); | |
|
85 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
86 | //![5] | |
|
87 | //![6] | |
|
88 | QMainWindow window; | |
|
73 | 89 | window.setCentralWidget(chartView); |
|
74 | 90 | window.resize(400, 300); |
|
75 | 91 | window.show(); |
|
76 | ||
|
92 | //![6] | |
|
77 | 93 | return a.exec(); |
|
78 | 94 | } |
|
79 | 95 |
@@ -2,8 +2,4 | |||
|
2 | 2 | error( "Couldn't find the examples.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | TARGET = stackedbarchart |
|
5 |
SOURCES += main.cpp |
|
|
6 | chartwidget.cpp | |
|
7 | HEADERS += \ | |
|
8 | chartwidget.h | |
|
9 | ||
|
5 | SOURCES += main.cpp No newline at end of file |
@@ -1,6 +1,6 | |||
|
1 | 1 | #include "chartwidget.h" |
|
2 | 2 | |
|
3 |
Chart |
|
|
3 | ChartView::ChartView(QWidget *parent) : | |
|
4 | 4 | QChartView(parent) |
|
5 | 5 | { |
|
6 | 6 | } |
@@ -6,11 +6,11 | |||
|
6 | 6 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
7 | 7 | |
|
8 | 8 | |
|
9 |
class Chart |
|
|
9 | class ChartView : public QChartView | |
|
10 | 10 | { |
|
11 | 11 | Q_OBJECT |
|
12 | 12 | public: |
|
13 |
explicit Chart |
|
|
13 | explicit ChartView(QWidget *parent = 0); | |
|
14 | 14 | |
|
15 | 15 | signals: |
|
16 | 16 |
@@ -1,45 +1,87 | |||
|
1 | #include "chartwidget.h" | |
|
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:BSD$ | |
|
10 | ** You may use this file under the terms of the BSD license as follows: | |
|
11 | ** | |
|
12 | ** "Redistribution and use in source and binary forms, with or without | |
|
13 | ** modification, are permitted provided that the following conditions are | |
|
14 | ** met: | |
|
15 | ** * Redistributions of source code must retain the above copyright | |
|
16 | ** notice, this list of conditions and the following disclaimer. | |
|
17 | ** * Redistributions in binary form must reproduce the above copyright | |
|
18 | ** notice, this list of conditions and the following disclaimer in | |
|
19 | ** the documentation and/or other materials provided with the | |
|
20 | ** distribution. | |
|
21 | ** * Neither the name of Digia nor the names of its contributors | |
|
22 | ** may be used to endorse or promote products derived from this | |
|
23 | ** software without specific prior written permission. | |
|
24 | ** | |
|
25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
|
26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
|
27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
|
28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
|
29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
|
30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
|
31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
|
32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
|
33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
|
34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
|
35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." | |
|
36 | ** $QT_END_LICENSE$ | |
|
37 | ** | |
|
38 | ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). | |
|
39 | ** | |
|
40 | ****************************************************************************/ | |
|
41 | ||
|
42 | #include "chartview.h" | |
|
2 | 43 | #include <QApplication> |
|
3 | 44 | #include <QMainWindow> |
|
4 | 45 | #include <QLineSeries> |
|
5 | #include <cmath> | |
|
6 | 46 | |
|
7 | 47 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | 48 | |
|
9 | #define PI 3.14159265358979 | |
|
10 | ||
|
11 | 49 | int main(int argc, char *argv[]) |
|
12 | 50 | { |
|
13 | 51 | QApplication a(argc, argv); |
|
14 | 52 | |
|
15 | QMainWindow window; | |
|
16 | ||
|
53 | //![1] | |
|
17 | 54 | QLineSeries* series0 = new QLineSeries(); |
|
18 | 55 | QPen blue(Qt::blue); |
|
19 | 56 | blue.setWidth(3); |
|
20 | 57 | series0->setPen(blue); |
|
58 | ||
|
21 | 59 | QLineSeries* series1 = new QLineSeries(); |
|
22 | 60 | QPen red(Qt::red); |
|
23 | 61 | red.setWidth(3); |
|
24 | 62 | series1->setPen(red); |
|
63 | //![1] | |
|
64 | //![2] | |
|
65 | *series0 << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10, 5); | |
|
66 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); | |
|
67 | //![2] | |
|
68 | //![3] | |
|
69 | QChart* chart = new QChart(); | |
|
25 | 70 | |
|
26 | int numPoints = 100; | |
|
27 | ||
|
28 | for (int x = 0; x <= numPoints; ++x) { | |
|
29 | series0->add(x, fabs(sin(PI/50*x)*100)); | |
|
30 | series1->add(x, fabs(cos(PI/50*x)*100)); | |
|
31 | } | |
|
32 | ||
|
33 | ChartWidget* chartWidget = new ChartWidget(&window); | |
|
34 | chartWidget->setRenderHint(QPainter::Antialiasing); | |
|
35 | chartWidget->setChartTitle("Zoom in/out line chart example"); | |
|
36 | chartWidget->setAnimationOptions(QChart::AllAnimations); | |
|
37 | chartWidget->addSeries(series0); | |
|
38 | chartWidget->addSeries(series1); | |
|
39 | ||
|
40 | window.setCentralWidget(chartWidget); | |
|
41 | window.resize(400, 300); | |
|
42 | window.show(); | |
|
43 | ||
|
71 | chart->addSeries(series0); | |
|
72 | chart->addSeries(series1); | |
|
73 | chart->setTitle("Zoom in/out chart example"); | |
|
74 | chart->setAnimationOptions(QChart::AllAnimations); | |
|
75 | //![3] | |
|
76 | //![4] | |
|
77 | ChartView* chartView = new ChartView(chart); | |
|
78 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
79 | //![4] | |
|
80 | //![5] | |
|
81 | QMainWindow window; | |
|
82 | window.setCentralWidget(chartView); | |
|
83 | window.resize(400, 300); | |
|
84 | window.show(); | |
|
85 | //![5] | |
|
44 | 86 | return a.exec(); |
|
45 | 87 | } |
@@ -2,8 +2,8 | |||
|
2 | 2 | error( "Couldn't find the examples.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | TARGET = zoomlinechart |
|
5 |
HEADERS += chart |
|
|
6 |
SOURCES += main.cpp chart |
|
|
5 | HEADERS += chartview.h | |
|
6 | SOURCES += main.cpp chartview.cpp | |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
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