diff options
Diffstat (limited to 'examples/boxplotchart')
-rw-r--r-- | examples/boxplotchart/acme_data.txt | 13 | ||||
-rw-r--r-- | examples/boxplotchart/boxdatareader.cpp | 79 | ||||
-rw-r--r-- | examples/boxplotchart/boxdatareader.h | 43 | ||||
-rw-r--r-- | examples/boxplotchart/boxplotchart.pro | 13 | ||||
-rw-r--r-- | examples/boxplotchart/boxplotdata.qrc | 6 | ||||
-rw-r--r-- | examples/boxplotchart/boxwhisk_data.txt | 13 | ||||
-rw-r--r-- | examples/boxplotchart/main.cpp | 105 |
7 files changed, 0 insertions, 272 deletions
diff --git a/examples/boxplotchart/acme_data.txt b/examples/boxplotchart/acme_data.txt deleted file mode 100644 index 9511418d..00000000 --- a/examples/boxplotchart/acme_data.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Acme Ltd share deviation in 2012 -Jan 27.74 27.28 27.86 28.05 28.64 27.47 28.30 28.22 28.72 26.50 26.62 26.50 26.15 26.47 26.41 25.78 24.82 24.89 24.88 24.60 23.85 -Feb 31.79 30.62 30.67 31.37 31.16 31.22 32.02 32.70 31.60 31.24 30.98 30.79 31.10 30.79 31.53 30.92 30.00 30.58 30.37 29.40 28.60 -Mar 28.64 28.34 29.13 29.43 30.75 29.77 29.72 30.52 31.12 33.05 32.51 32.69 31.83 32.47 31.41 31.39 31.78 30.08 29.46 31.58 31.39 31.41 -Apr 25.96 26.62 26.19 30.37 28.78 27.50 28.90 28.40 28.86 28.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 28.96 28.50 -May 20.85 21.08 21.98 21.61 21.45 21.73 21.71 22.27 21.14 20.65 21.95 22.23 23.17 24.26 24.17 22.97 23.53 24.49 24.51 25.46 25.65 -Jun 18.08 17.19 17.36 17.21 17.31 18.19 18.30 17.53 17.35 17.80 17.17 16.95 18.25 20.52 20.61 21.40 20.45 19.43 19.11 19.74 -Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 18.00 18.03 18.14 18.10 17.86 18.12 18.53 18.43 18.30 19.03 18.76 18.79 18.33 -Aug 18.69 18.54 18.39 18.49 18.96 18.72 19.25 19.70 20.13 19.74 19.27 18.25 17.72 18.02 18.20 18.24 18.60 18.22 18.60 17.98 17.27 16.70 17.19 -Sep 18.35 18.82 18.96 19.96 19.75 20.55 20.68 21.19 21.14 21.48 21.45 20.74 20.97 20.18 19.66 19.54 18.89 18.39 18.26 18.86 -Oct 16.95 16.80 16.45 16.89 17.38 17.12 16.85 17.59 17.65 17.46 17.43 17.30 17.87 18.61 18.55 18.59 19.27 19.54 20.02 19.23 18.05 18.52 18.71 -Now 19.36 19.29 18.22 18.74 19.05 19.13 18.67 18.19 17.94 18.04 17.49 17.53 17.64 18.00 18.21 18.19 18.30 18.11 18.17 17.76 17.80 17.52 -Dec 19.95 20.19 20.15 20.42 20.39 20.65 20.39 19.86 19.48 19.70 19.94 19.82 20.25 20.21 19.63 19.55 diff --git a/examples/boxplotchart/boxdatareader.cpp b/examples/boxplotchart/boxdatareader.cpp deleted file mode 100644 index ba2d8b3a..00000000 --- a/examples/boxplotchart/boxdatareader.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "boxdatareader.h" - -BoxDataReader::BoxDataReader(QIODevice *device) : - QTextStream(device) -{ -} - -void BoxDataReader::readFile(QIODevice *device) -{ - QTextStream::setDevice(device); -} - -QBoxSet *BoxDataReader::readBox() -{ - //! [1] - QString line = readLine(); - if (line.startsWith("#")) - return 0; - //! [1] - - //! [2] - QStringList strList = line.split(" ", QString::SkipEmptyParts); - //! [2] - - //! [3] - sortedList.clear(); - for (int i = 1; i < strList.count(); i++) - sortedList.append(strList.at(i).toDouble()); - - qSort(sortedList.begin(), sortedList.end()); - //! [3] - - int count = sortedList.count(); - - //! [4] - QBoxSet *box = new QBoxSet(strList.first()); - box->setValue(QBoxSet::LowerExtreme, sortedList.first()); - box->setValue(QBoxSet::UpperExtreme, sortedList.last()); - box->setValue(QBoxSet::Median, findMedian(0, count)); - box->setValue(QBoxSet::LowerQuartile, findMedian(0, count / 2)); - box->setValue(QBoxSet::UpperQuartile, findMedian(count / 2 + (count % 2), count)); - //! [4] - - return box; -} - -qreal BoxDataReader::findMedian(int begin, int end) -{ - //! [5] - int count = end - begin; - if (count % 2) { - return sortedList.at(count / 2 + begin); - } else { - qreal right = sortedList.at(count / 2 + begin); - qreal left = sortedList.at(count / 2 - 1 + begin); - return (right + left) / 2.0; - } - //! [5] -} diff --git a/examples/boxplotchart/boxdatareader.h b/examples/boxplotchart/boxdatareader.h deleted file mode 100644 index 8f1e9c51..00000000 --- a/examples/boxplotchart/boxdatareader.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOXDATAREADER_H -#define BOXDATAREADER_H - -#include <QTextStream> -#include <QBoxSet> - -QTCOMMERCIALCHART_USE_NAMESPACE - -class BoxDataReader : public QTextStream -{ -public: - explicit BoxDataReader(QIODevice *device); - QBoxSet *readBox(); - void readFile(QIODevice *device); - -protected: - qreal findMedian(int begin, int end); - -private: - QList<qreal> sortedList; -}; - -#endif // BOXDATAREADER_H diff --git a/examples/boxplotchart/boxplotchart.pro b/examples/boxplotchart/boxplotchart.pro deleted file mode 100644 index c2483511..00000000 --- a/examples/boxplotchart/boxplotchart.pro +++ /dev/null @@ -1,13 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -TARGET = boxplotchart -SOURCES += main.cpp \ - boxdatareader.cpp - -RESOURCES += \ - boxplotdata.qrc - -HEADERS += \ - boxdatareader.h diff --git a/examples/boxplotchart/boxplotdata.qrc b/examples/boxplotchart/boxplotdata.qrc deleted file mode 100644 index fe6d52b5..00000000 --- a/examples/boxplotchart/boxplotdata.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file alias="acme">acme_data.txt</file> - <file alias="boxwhisk">boxwhisk_data.txt</file> - </qresource> -</RCC> diff --git a/examples/boxplotchart/boxwhisk_data.txt b/examples/boxplotchart/boxwhisk_data.txt deleted file mode 100644 index f1d49cf0..00000000 --- a/examples/boxplotchart/boxwhisk_data.txt +++ /dev/null @@ -1,13 +0,0 @@ -# BoxWhisk Inc share deviation in 2012 -Jan 25.74 25.28 25.86 26.05 26.64 28.47 28.30 29.22 29.72 27.50 25.62 25.50 25.15 26.47 27.41 25.78 24.82 24.89 24.88 24.60 23.85 -Feb 30.79 29.62 29.67 30.37 30.16 30.22 31.02 33.70 32.60 32.24 31.98 31.79 31.10 30.79 31.53 30.92 29.00 29.58 30.37 29.40 28.60 -Mar 29.64 29.34 30.13 30.43 31.75 30.77 30.72 31.52 32.12 33.75 33.51 33.69 32.83 32.47 32.41 32.39 32.78 31.08 29.46 31.58 31.39 31.41 -Apr 24.96 25.62 25.19 28.37 28.78 26.50 25.90 26.40 26.86 26.90 27.91 27.32 27.99 26.86 26.68 27.57 27.50 26.96 26.50 -May 21.85 21.08 22.98 22.61 22.45 21.73 21.71 23.27 22.14 19.65 22.95 21.23 23.17 24.26 24.17 21.97 22.53 25.49 25.51 26.46 26.65 -Jun 15.08 15.19 15.36 15.21 15.31 18.19 18.30 15.53 15.35 15.80 15.17 16.95 18.25 20.52 20.61 20.40 20.45 19.43 19.11 19.74 -Jul 17.75 18.24 17.57 16.53 15.98 16.06 16.64 17.69 17.91 19.00 19.03 19.14 19.10 17.86 19.12 19.53 19.43 19.30 19.03 19.76 18.79 18.33 -Aug 19.69 19.54 19.39 19.49 19.96 19.72 20.25 20.70 21.13 20.74 20.27 19.25 18.72 19.02 19.20 19.24 19.60 19.22 19.60 18.98 18.27 17.70 18.19 -Sep 19.35 19.82 19.96 20.96 20.75 21.55 21.68 22.19 22.14 22.48 22.45 21.74 21.97 21.18 20.66 20.54 19.89 19.39 19.26 19.86 -Oct 17.95 17.80 17.45 17.89 18.38 18.12 17.85 18.59 18.65 18.46 18.43 18.30 18.87 19.61 19.55 19.59 20.27 20.54 21.02 20.23 19.05 19.52 19.71 -Now 20.36 20.29 19.22 19.74 20.05 20.13 19.67 19.19 18.94 19.04 18.49 18.53 18.64 19.00 19.21 19.19 19.30 19.11 19.17 18.76 18.80 18.52 -Dec 22.95 22.19 22.15 21.42 21.39 21.65 22.39 20.86 20.48 20.70 20.94 20.82 19.25 21.21 19.63 20.55 diff --git a/examples/boxplotchart/main.cpp b/examples/boxplotchart/main.cpp deleted file mode 100644 index 78ce7a54..00000000 --- a/examples/boxplotchart/main.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the Qt Enterprise Charts Add-on. -** -** $QT_BEGIN_LICENSE$ -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> -#include <QMainWindow> -#include <QChartView> -#include <QBoxPlotSeries> -#include <QBoxSet> -#include <QLegend> -#include <QBarCategoryAxis> -#include <QFile> - -#include "boxdatareader.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - //! [1] - QBoxPlotSeries *acmeSeries = new QBoxPlotSeries(); - acmeSeries->setName("Acme Ltd"); - - QBoxPlotSeries *boxWhiskSeries = new QBoxPlotSeries(); - boxWhiskSeries->setName("BoxWhisk Inc"); - //! [1] - - //! [2] - QFile acmeData(":acme"); - if (!acmeData.open(QIODevice::ReadOnly | QIODevice::Text)) - return 1; - - BoxDataReader dataReader(&acmeData); - while (!dataReader.atEnd()) { - QBoxSet *set = dataReader.readBox(); - if (set) - acmeSeries->append(set); - } - //! [2] - - //! [3] - QFile boxwhiskData(":boxwhisk"); - if (!boxwhiskData.open(QIODevice::ReadOnly | QIODevice::Text)) - return 1; - - dataReader.readFile(&boxwhiskData); - while (!dataReader.atEnd()) { - QBoxSet *set = dataReader.readBox(); - if (set) - boxWhiskSeries->append(set); - } - //! [3] - - //! [4] - QChart *chart = new QChart(); - chart->addSeries(acmeSeries); - chart->addSeries(boxWhiskSeries); - chart->setTitle("Acme Ltd and BoxWhisk Inc share deviation in 2012"); - chart->setAnimationOptions(QChart::SeriesAnimations); - //! [4] - - //! [5] - chart->createDefaultAxes(); - chart->axisY()->setMin(15.0); - chart->axisY()->setMax(34.0); - //! [5] - - //! [6] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); - //! [6] - - //! [7] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); - //! [7] - - //! [8] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(800, 600); - window.show(); - //! [8] - - return a.exec(); -} - |