##// END OF EJS Templates
Combines color,axis,custom into one example
Michal Klocek -
r767:ab751f5c733f
parent child
Show More
@@ -1,9 +1,9
1 !include( ../examples.pri ) {
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
2 error( "Couldn't find the examples.pri file!" )
3 }
3 }
4
4
5 TARGET = colorlinechart
5 TARGET = customechart
6 SOURCES += main.cpp
6 SOURCES += main.cpp
7
7
8
8
9
9
@@ -1,95 +1,124
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:BSD$
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
10 ** You may use this file under the terms of the BSD license as follows:
11 **
11 **
12 ** "Redistribution and use in source and binary forms, with or without
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
13 ** modification, are permitted provided that the following conditions are
14 ** met:
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
19 ** the documentation and/or other materials provided with the
20 ** distribution.
20 ** distribution.
21 ** * Neither the name of Digia nor the names of its contributors
21 ** * Neither the name of Digia nor the names of its contributors
22 ** may be used to endorse or promote products derived from this
22 ** may be used to endorse or promote products derived from this
23 ** software without specific prior written permission.
23 ** software without specific prior written permission.
24 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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."
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 ** $QT_END_LICENSE$
36 ** $QT_END_LICENSE$
37 **
37 **
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
38 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
39 **
39 **
40 ****************************************************************************/
40 ****************************************************************************/
41
41
42 #include <QApplication>
42 #include <QApplication>
43 #include <QMainWindow>
43 #include <QMainWindow>
44 #include <QChartView>
44 #include <QChartView>
45 #include <QLineSeries>
45 #include <QLineSeries>
46
46
47 QTCOMMERCIALCHART_USE_NAMESPACE
47 QTCOMMERCIALCHART_USE_NAMESPACE
48
48
49 int main(int argc, char *argv[])
49 int main(int argc, char *argv[])
50 {
50 {
51 QApplication a(argc, argv);
51 QApplication a(argc, argv);
52
52
53 //![1]
53 //![1]
54 QLineSeries* series = new QLineSeries();
54 QLineSeries* series = new QLineSeries();
55 QPen blue(Qt::blue);
55 QPen blue(Qt::yellow);
56 blue.setWidth(3);
56 blue.setWidth(3);
57 series->setPen(blue);
57 series->setPen(blue);
58 //![1]
58 //![1]
59 //![2]
59 //![2]
60 *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5);
60 *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5);
61 //![2]
61 //![2]
62 //![3]
62 //![3]
63 QChart* chart = new QChart();
63 QChart* chart = new QChart();
64 chart->addSeries(series);
64 chart->addSeries(series);
65 chart->setTitle("Custom colors example");
65 chart->setTitle("Simple customchart example");
66 //![3]
66 //![3]
67 //![4]
67 //![4]
68 QFont font;
68 QFont font;
69 font.setPixelSize(18);
69 font.setPixelSize(18);
70 chart->setTitleFont(font);
70 chart->setTitleFont(font);
71 chart->setTitleBrush(Qt::red);
71 chart->setTitleBrush(Qt::yellow);
72
72
73 QLinearGradient backgroundGradient;
73 QLinearGradient backgroundGradient;
74 backgroundGradient.setColorAt(0.0, Qt::lightGray);
74 backgroundGradient.setStart(QPointF(0,0));
75 backgroundGradient.setColorAt(1.0, Qt::white);
75 backgroundGradient.setFinalStop(QPointF(0,1));
76 backgroundGradient.setColorAt(0.0, 0x3cc63c);
77 backgroundGradient.setColorAt(1.0, 0x26f626);
76 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
78 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
77 chart->setBackgroundBrush(backgroundGradient);
79 chart->setBackgroundBrush(backgroundGradient);
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]
80 //![4]
85 //![5]
81 //![5]
82 QPen black(Qt::black);
83 QChartAxis* axisX = chart->axisX();
84 QChartAxis* axisY = chart->axisY();
85
86 axisX->setAxisPen(black);
87 axisY->setAxisPen(black);
88 axisX->setGridLineVisible(false);
89 axisY->setGridLineVisible(false);
90
91 axisY->setShadesPen(Qt::NoPen);
92 axisY->setShadesOpacity(0.5);
93 axisY->setShadesBrush(Qt::white);
94 axisY->setShadesVisible(true);
95 //![5]
96 //![6]
97 QChartAxisCategories* categoriesX = chart->axisX()->categories();
98 categoriesX->insert(1,"low");
99 categoriesX->insert(5,"optimal");
100 categoriesX->insert(10,"high");
101
102 QChartAxisCategories* categoriesY = chart->axisY()->categories();
103 categoriesY->insert(1,"slow");
104 categoriesY->insert(5,"med");
105 categoriesY->insert(10,"fast");
106 //![6]
107 //![7]
108 axisX->setRange(0,10);
109 axisX->setTicksCount(4);
110 axisY->setRange(0,10);
111 axisY->setTicksCount(4);
112 //![7]
113 //![8]
86 QChartView* chartView = new QChartView(chart);
114 QChartView* chartView = new QChartView(chart);
87 chartView->setRenderHint(QPainter::Antialiasing);
115 chartView->setRenderHint(QPainter::Antialiasing);
88 //![5]
116 //![8]
117 //![9]
89 QMainWindow window;
118 QMainWindow window;
90 window.setCentralWidget(chartView);
119 window.setCentralWidget(chartView);
91 window.resize(400, 300);
120 window.resize(400, 300);
92 window.show();
121 window.show();
93 //![5]
122 //![9]
94 return a.exec();
123 return a.exec();
95 }
124 }
@@ -1,32 +1,30
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += \
2 SUBDIRS += \
3 areachart \
3 areachart \
4 #axischart \
5 barchart \
4 barchart \
6 #chartview \
5 #chartview \
7 colorlinechart \
6 customchart \
8 #customcolors \
9 #dynamiclinechart \
7 #dynamiclinechart \
10 #ekgchart \
8 #ekgchart \
11 #gdpbarchart \
9 #gdpbarchart \
12 linechart \
10 linechart \
13 #multichart \
11 #multichart \
14 percentbarchart \
12 percentbarchart \
15 piechart \
13 piechart \
16 #piechartdrilldown \
14 #piechartdrilldown \
17 #presenterchart \
15 #presenterchart \
18 scatterchart \
16 scatterchart \
19 #scatterinteractions \
17 #scatterinteractions \
20 #splinechart \
18 #splinechart \
21 stackedbarchart \
19 stackedbarchart \
22 #stackedbarchartdrilldown \
20 #stackedbarchartdrilldown \
23 #tablemodelchart \
21 #tablemodelchart \
24 zoomlinechart
22 zoomlinechart
25
23
26
24
27
25
28
26
29
27
30
28
31
29
32
30
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now