diff options
author | Mika Salmela <mika.salmela@digia.com> | 2013-06-06 14:57:44 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2013-06-06 15:19:33 +0300 |
commit | 89b8a97da4fc6bdd4a0e1fd52ee57701c4615145 (patch) | |
tree | 815443317fe8fa5fdd3ebd58e7fbc3d9d6381a16 /examples/boxplotchart/main.cpp | |
parent | 8f0e18a7e02cc4f9018d95379efbfb9cf167dd56 (diff) |
Example finalization and documentation
Change-Id: I0ccfa85c689bf6f9519fcce5eb38941de6d8d492
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'examples/boxplotchart/main.cpp')
-rw-r--r-- | examples/boxplotchart/main.cpp | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/examples/boxplotchart/main.cpp b/examples/boxplotchart/main.cpp index 7ebb6093..c4b04355 100644 --- a/examples/boxplotchart/main.cpp +++ b/examples/boxplotchart/main.cpp @@ -33,52 +33,71 @@ QTCOMMERCIALCHART_USE_NAMESPACE int main(int argc, char *argv[]) { QApplication a(argc, argv); -//![1] -//![2] - QBoxPlotSeries *series = new QBoxPlotSeries(); - series->setName("Acme Ltd"); -//![2] + //! [1] + QBoxPlotSeries *acmeSeries = new QBoxPlotSeries(); + acmeSeries->setName("Acme Ltd"); - QFile stockData(":stock"); - if (!stockData.open(QIODevice::ReadOnly | QIODevice::Text)) + 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; - BoxDataReader dataReader(&stockData); + dataReader.readFile(&boxwhiskData); while (!dataReader.atEnd()) { QBoxSet *set = dataReader.readBox(); if (set) - series->append(set); + boxWhiskSeries->append(set); } + //! [3] -//![3] + //! [4] QChart *chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Acme's share deviation in 2012"); + chart->addSeries(acmeSeries); + chart->addSeries(boxWhiskSeries); + chart->setTitle("Acme Ltd and BoxWhisk Inc share deviation in 2012"); chart->setAnimationOptions(QChart::SeriesAnimations); -//![3] + //! [4] -//![4] + //! [5] chart->createDefaultAxes(); chart->axisY()->setMin(15.0); -//![4] + chart->axisY()->setMax(34.0); + //! [5] -//![5] + //! [6] chart->legend()->setVisible(true); chart->legend()->setAlignment(Qt::AlignBottom); -//![5] + //! [6] -//![6] + //! [7] QChartView *chartView = new QChartView(chart); chartView->setRenderHint(QPainter::Antialiasing); -//![6] + //! [7] -//![7] + //! [8] QMainWindow window; window.setCentralWidget(chartView); - window.resize(600, 400); + window.resize(800, 600); window.show(); -//![7] + //! [8] return a.exec(); } |