##// END OF EJS Templates
Initial example application for boxplot....
Mika Salmela -
r2463:0948467685b7
parent child
Show More
@@ -0,0 +1,5
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
3 }
4 TARGET = boxplotchart
5 SOURCES += main.cpp
@@ -0,0 +1,107
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 <QBoxPlotSeries>
25 #include <QBarSet>
26 #include <QLegend>
27 #include <QBarCategoryAxis>
28
29 #include <QBrush>
30 #include <QColor>
31
32 QTCOMMERCIALCHART_USE_NAMESPACE
33
34 int main(int argc, char *argv[])
35 {
36 QApplication a(argc, argv);
37
38 //![1]
39 QBarSet *set0 = new QBarSet("Jan");
40 QBarSet *set1 = new QBarSet("Feb");
41 QBarSet *set2 = new QBarSet("Mar");
42 QBarSet *set3 = new QBarSet("Apr");
43 QBarSet *set4 = new QBarSet("May");
44 QBarSet *set5 = new QBarSet("Jun");
45
46 // low bot med top upp
47 *set0 << 3 << 4 << 4.4 << 6 << 7;
48 *set1 << 5 << 6 << 7.5 << 8 << 12;
49 *set2 << 3 << 5 << 5.7 << 8 << 9;
50 *set3 << 5 << 6 << 6.8 << 7 << 8;
51 *set4 << 4 << 5 << 5.2 << 6 << 7;
52 *set5 << 4 << 7 << 8.2 << 9 << 10;
53
54 set0->setBrush(QBrush(QColor(Qt::yellow)));
55
56 //set0->setColor(QColor(Qt::darkRed));
57 //![1]
58
59 //![2]
60 QBoxPlotSeries *series = new QBoxPlotSeries();
61 series->append(set0);
62 series->append(set1);
63 series->append(set2);
64 series->append(set3);
65 series->append(set4);
66 series->append(set5);
67 series->type();
68 series->setName("Box & Whiskers");
69 //series->setBrush(QBrush(QColor(Qt::yellow)));
70 //![2]
71
72 //![3]
73 QChart *chart = new QChart();
74 chart->addSeries(series);
75 chart->setTitle("Simple boxplotchart example");
76 chart->setAnimationOptions(QChart::SeriesAnimations);
77 //![3]
78
79 //![4]
80 QStringList categories;
81 categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
82 QBarCategoryAxis *axis = new QBarCategoryAxis();
83 axis->append(categories);
84 chart->createDefaultAxes();
85 chart->setAxisX(axis, series);
86 //![4]
87
88 //![5]
89 chart->legend()->setVisible(true);
90 chart->legend()->setAlignment(Qt::AlignBottom);
91 //![5]
92
93 //![6]
94 QChartView *chartView = new QChartView(chart);
95 chartView->setRenderHint(QPainter::Antialiasing);
96 //![6]
97
98 //![7]
99 QMainWindow window;
100 window.setCentralWidget(chartView);
101 window.resize(400, 300);
102 window.show();
103 //![7]
104
105 return a.exec();
106 }
107
General Comments 0
You need to be logged in to leave comments. Login now