Uninfy examples , updated public API changes

This commit is contained in:
Michal Klocek 2012-03-27 20:25:52 +03:00
parent 646ccd5c02
commit 917f2d3781
24 changed files with 617 additions and 503 deletions

View File

@ -1,57 +1,94 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <QChartView>
#include <QLineSeries>
#include <QAreaSeries>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//![1]
QLineSeries* series0 = new QLineSeries();
QLineSeries* series1 = new QLineSeries();
//![1]
//![2]
*series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12,6) << QPointF(16,7) << QPointF(18,5);
*series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12,3) << QPointF(16,4) << QPointF(18,3);
*series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) << QPointF(12, 6)
<< QPointF(16, 7) << QPointF(18, 5);
*series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) << QPointF(12, 3)
<< QPointF(16, 4) << QPointF(18, 3);
//![2]
//![3]
QAreaSeries* series = new QAreaSeries(series0,series1);
QAreaSeries* series = new QAreaSeries(series0, series1);
QPen pen(0x059605);
pen.setWidth(3);
series->setPen(pen);
QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1));
gradient.setColorAt(0.0,0x3cc63c);
gradient.setColorAt(0.0, 0x3cc63c);
gradient.setColorAt(1.0, 0x26f626);
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
series->setBrush(gradient);
//![3]
//![4]
QMainWindow window;
QChartView* chartView = new QChartView(&window);
chartView->setChartTitle("Simple area chart example");
chartView->setRenderHint(QPainter::Antialiasing);
chartView->addSeries(series);
chartView->axisX()->setRange(0,20);
chartView->axisY()->setRange(0,10);
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple areachart example");
chart->axisX()->setRange(0, 20);
chart->axisY()->setRange(0, 10);
//![4]
//![5]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![5]
//![6]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![5]
//![6]
return a.exec();
}

View File

@ -3,8 +3,5 @@
}
TARGET = barchart
SOURCES += main.cpp \
chartwidget.cpp
HEADERS += \
chartwidget.h
SOURCES += main.cpp

View File

@ -1,6 +0,0 @@
#include "chartwidget.h"
ChartWidget::ChartWidget(QWidget *parent) :
QChartView(parent)
{
}

View File

@ -1,21 +0,0 @@
#ifndef CHARTWIDGET_H
#define CHARTWIDGET_H
#include <qchartview.h>
QTCOMMERCIALCHART_USE_NAMESPACE
class ChartWidget : public QChartView
{
Q_OBJECT
public:
explicit ChartWidget(QWidget *parent = 0);
signals:
public slots:
};
#endif // CHARTWIDGET_H

View File

@ -1,27 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
#include <qbarseries.h>
#include <qbarset.h>
#include <qchartaxis.h>
#include <QStringList>
#include <QChartView>
#include <QBarSeries>
#include <QBarSet>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
//! [1]
// Define categories
QStringList categories;
//![1]
QBarCategories categories;
categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
//! [1]
//! [2]
// Create some test sets for chat
//![1]
//![2]
QBarSet *set0 = new QBarSet("Bub");
QBarSet *set1 = new QBarSet("Bob");
QBarSet *set2 = new QBarSet("Guybrush");
@ -33,48 +66,29 @@ int main(int argc, char *argv[])
*set2 << 3 << 5 << 8 << 13 << 8 << 5;
*set3 << 5 << 6 << 7 << 3 << 4 << 5;
*set4 << 9 << 7 << 5 << 3 << 1 << 2;
//! [2]
//! [3]
// Create series and add sets to it
QBarSeries* series= new QBarSeries(categories);
//![2]
//![3]
QBarSeries* series = new QBarSeries(categories);
series->addBarSet(set0);
series->addBarSet(set1);
series->addBarSet(set2);
series->addBarSet(set3);
series->addBarSet(set4);
//! [3]
//! [4]
// Enable tooltip
series->setToolTipEnabled();
// Connect clicked signal of set to toggle floating values of set.
QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues()));
QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues()));
QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues()));
QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues()));
QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues()));
//! [4]
//! [5]
// Create view for chart and add series to it. Apply theme.
QChartView* chartView = new QChartView(&window);
chartView->addSeries(series);
chartView->setChartTitle("simple barchart");
chartView->setChartTheme(QChart::ChartThemeIcy);
//! [5]
//! [6]
chartView->axisX()->setGridLineVisible(false);
//! [6]
//![3]
//![4]
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple barchart example");
//![4]
//![5]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![5]
//![6]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![6]
return a.exec();
}

View File

@ -1,55 +1,95 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
#include <qlineseries.h>
#include <qchart.h>
#include <cmath>
#include <QChartView>
#include <QLineSeries>
QTCOMMERCIALCHART_USE_NAMESPACE
#define PI 3.14159265358979
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QLineSeries* series0 = new QLineSeries();
//![1]
QLineSeries* series = new QLineSeries();
QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
QLineSeries* series1 = new QLineSeries();
QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
int numPoints = 100;
for (int x = 0; x <= numPoints; ++x) {
series0->add(x, fabs(sin(PI/50*x)*100));
series1->add(x, fabs(cos(PI/50*x)*100));
}
QChartView* chartView = new QChartView(&window);
chartView->setRenderHint(QPainter::Antialiasing);
series->setPen(blue);
//![1]
//![2]
*series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5);
//![2]
//![3]
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Custom colors example");
//![3]
//![4]
QFont font;
font.setPixelSize(18);
chartView->setChartTitleFont(font);
chartView->setChartTitle("Custom color line chart example");
chartView->addSeries(series0);
chartView->addSeries(series1);
chart->setTitleFont(font);
chart->setTitleBrush(Qt::red);
QLinearGradient backgroundGradient;
backgroundGradient.setColorAt(0.0, Qt::blue);
backgroundGradient.setColorAt(1.0, Qt::yellow);
backgroundGradient.setColorAt(0.0, Qt::lightGray);
backgroundGradient.setColorAt(1.0, Qt::white);
backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
chartView->setChartBackgroundBrush(backgroundGradient);
chart->setBackgroundBrush(backgroundGradient);
QPen black(Qt::black);
chart->axisX()->setGridLinePen(black);
chart->axisX()->setAxisPen(black);
chart->axisY()->setGridLinePen(black);
chart->axisY()->setAxisPen(black);
//![4]
//![5]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![5]
return a.exec();
}

View File

@ -1,23 +1,32 @@
TEMPLATE = subdirs
SUBDIRS += linechart \
zoomlinechart \
colorlinechart \
barchart \
stackedbarchart \
percentbarchart \
scatterchart \
piechart \
piechartdrilldown \
dynamiclinechart \
axischart \
multichart \
gdpbarchart \
presenterchart \
chartview \
scatterinteractions \
splinechart \
SUBDIRS += \
areachart \
stackedbarchartdrilldown \
customcolors \
tablemodelchart \
ekgchart
#axischart \
barchart \
#chartview \
colorlinechart \
#customcolors \
#dynamiclinechart \
#ekgchart \
#gdpbarchart \
linechart \
#multichart \
percentbarchart \
piechart \
#piechartdrilldown \
#presenterchart \
scatterchart \
#scatterinteractions \
#splinechart \
stackedbarchart \
#stackedbarchartdrilldown \
#tablemodelchart \
zoomlinechart

View File

@ -1,15 +1,54 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <QChartView>
#include <QLineSeries>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//![1]
QLineSeries* series0 = new QLineSeries();
QPen blue(Qt::blue);
@ -27,25 +66,26 @@ int main(int argc, char *argv[])
series0->add(2, 4);
series0->add(3, 8);
series0->add(7, 4);
series0->add(10,5);
series0->add(10, 5);
*series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10,2);
*series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
//![2]
//![3]
QMainWindow window;
QChartView* chartView = new QChartView(&window);
QChart* chart = new QChart();
chartView->setChartTitle("Simple line chart");
chartView->setRenderHint(QPainter::Antialiasing);
chartView->addSeries(series0);
chartView->addSeries(series1);
chart->addSeries(series0);
chart->addSeries(series1);
chart->setTitle("Simple line chart example");
//![3]
//![4]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![4]
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![4]
//![5]
return a.exec();
}

View File

@ -1,6 +0,0 @@
#include "chartwidget.h"
ChartWidget::ChartWidget(QWidget *parent) :
QChartView(parent)
{
}

View File

@ -1,16 +0,0 @@
#ifndef CHARTWIDGET_H
#define CHARTWIDGET_H
#include <qchartview.h>
QTCOMMERCIALCHART_USE_NAMESPACE
class ChartWidget : public QChartView
{
Q_OBJECT
public:
explicit ChartWidget(QWidget *parent = 0);
};
#endif // CHARTWIDGET_H

View File

@ -1,27 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <QStandardItemModel>
#include <qpercentbarseries.h>
#include <qchartview.h>
#include <qbarset.h>
#include <qchartaxis.h>
#include <QStringList>
#include <QChartView>
#include <QPercentBarSeries>
#include <QBarSet>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
//! [1]
// Define categories
QStringList categories;
//![1]
QBarCategories categories;
categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
//! [1]
//! [2]
// Create some test sets for chat
//![1]
//![2]
QBarSet *set0 = new QBarSet("Bub");
QBarSet *set1 = new QBarSet("Bob");
QBarSet *set2 = new QBarSet("Guybrush");
@ -33,51 +66,30 @@ int main(int argc, char *argv[])
*set2 << 3 << 5 << 8 << 13 << 8 << 5;
*set3 << 5 << 6 << 7 << 3 << 4 << 5;
*set4 << 9 << 7 << 5 << 3 << 1 << 2;
//! [2]
//! [3]
// Create series and add sets to it
//![2]
//![3]
QPercentBarSeries* series = new QPercentBarSeries(categories);
series->addBarSet(set0);
series->addBarSet(set1);
series->addBarSet(set2);
series->addBarSet(set3);
series->addBarSet(set4);
//! [3]
//! [4]
// Enable tooltip
series->setToolTipEnabled();
// Connect clicked signal of set to toggle floating values of set.
// Note that we leave QBarset "Zak" unconnected here, so clicking on it doesn't toggle values.
QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues()));
QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues()));
QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues()));
QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues()));
QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues()));
//! [4]
//! [5]
// Create view for chart and add series to it. Apply theme.
QChartView* chartView = new QChartView(&window);
chartView->addSeries(series);
chartView->setChartTitle("simple percent barchart");
chartView->setChartTheme(QChart::ChartThemeIcy);
//! [5]
//! [6]
//chartView->axisX()->setAxisVisible(false);
chartView->axisX()->setGridLineVisible(false);
chartView->axisX()->setLabelsVisible(false);
//! [6]
//! [3]
//![4]
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple precentbarchart example");
//![4]
//![5]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![5]
//![6]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![6]
return a.exec();
}

View File

@ -3,8 +3,5 @@
}
TARGET = percentbarchart
SOURCES += main.cpp \
chartwidget.cpp
HEADERS += \
chartwidget.h
SOURCES += main.cpp

View File

@ -1,9 +1,49 @@
#include <QtGui/QApplication>
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <qchartglobal.h>
#include <qchartview.h>
#include <qpieseries.h>
#include <qpieslice.h>
#include <QChartView>
#include <QPieSeries>
#include <QPieSlice>
QTCOMMERCIALCHART_USE_NAMESPACE
@ -11,34 +51,36 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QChartView* chartView = new QChartView(&window);
chartView->setRenderHint(QPainter::Antialiasing);
chartView->setChartTitle("Simple pie chart");
//! [1]
//![1]
QPieSeries *series = new QPieSeries();
series->add(1, "Slice 1");
series->add(2, "Slice 2");
series->add(3, "Slice 3");
series->add(4, "Slice 4");
series->add(5, "Slice 5");
//! [1]
//![1]
//! [2]
//![2]
QPieSlice *slice = series->slices().first();
slice->setExploded();
slice->setLabelVisible();
slice->setSlicePen(QPen(Qt::darkGreen, 2));
slice->setSliceBrush(Qt::green);
//! [2]
chartView->addSeries(series);
//![2]
//![3]
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple piechart example");
//![3]
//![4]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![4]
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(600, 600);
window.resize(400, 300);
window.show();
//![5]
return a.exec();
}

View File

@ -1,3 +1,44 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QtGui/QApplication>
#include <QMainWindow>
#include <QChartView>
@ -8,41 +49,50 @@ QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//! [1]
QScatterSeries *scatter = new QScatterSeries();
QBrush brush(Qt::red);
//![1]
QPen pen(Qt::black);
pen.setWidth(2);
QBrush blue(Qt::blue);
QBrush red(Qt::red);
scatter->setPen(pen);
scatter->setBrush(brush);
scatter->setShape(QScatterSeries::MarkerShapeCircle);
scatter->setSize(15.0);
//! [1]
QScatterSeries *series0 = new QScatterSeries();
series0->setPen(pen);
series0->setBrush(blue);
series0->setShape(QScatterSeries::MarkerShapeCircle);
series0->setSize(15.0);
//! [2]
for (qreal i(0.0); i < 20; i += 0.5) {
qreal x = i + (qreal) (rand() % 100) / 100.0;
qreal y = i + (qreal) (rand() % 100) / 100.0;
scatter->add(x, y);
}
*scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
//! [2]
QScatterSeries *series1 = new QScatterSeries();
series1->setPen(pen);
series1->setBrush(red);
series1->setShape(QScatterSeries::MarkerShapeCircle);
series1->setSize(15.0);
//![1]
//! [3]
QMainWindow window;
QChartView *chartView = new QChartView(&window);
//![2]
series0->add(0, 6);
series0->add(2, 4);
series0->add(3, 8);
series0->add(7, 4);
series0->add(10, 5);
*series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
//![2]
//![3]
QChart* chart = new QChart();
chart->addSeries(series0);
chart->addSeries(series1);
chart->setTitle("Simple scatterchart example");
//![3]
//![4]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
chartView->setChartTitle("Simple scatter chart example");
chartView->addSeries(scatter);
//! [3]
//! [4]
//![4]
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//! [4]
//![5]
return a.exec();
}

View File

@ -1,6 +0,0 @@
#include "chartwidget.h"
ChartWidget::ChartWidget(QWidget *parent) :
QChartView(parent)
{
}

View File

@ -1,21 +0,0 @@
#ifndef CHARTWIDGET_H
#define CHARTWIDGET_H
#include <qchartview.h>
QTCOMMERCIALCHART_USE_NAMESPACE
class ChartWidget : public QChartView
{
Q_OBJECT
public:
explicit ChartWidget(QWidget *parent = 0);
signals:
public slots:
};
#endif // CHARTWIDGET_H

View File

@ -1,26 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
#include <qstackedbarseries.h>
#include <qbarset.h>
#include <qchartaxis.h>
#include <QStringList>
#include <QChartView>
#include <QStackedBarSeries>
#include <QBarSet>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
//! [1]
// Define categories
QStringList categories;
//![1]
QBarCategories categories;
categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
//! [1]
//! [2]
// Create some test sets for chat
//![1]
//![2]
QBarSet *set0 = new QBarSet("Bub");
QBarSet *set1 = new QBarSet("Bob");
QBarSet *set2 = new QBarSet("Guybrush");
@ -32,48 +66,30 @@ int main(int argc, char *argv[])
*set2 << 3 << 5 << 8 << 13 << 8 << 5;
*set3 << 5 << 6 << 7 << 3 << 4 << 5;
*set4 << 9 << 7 << 5 << 3 << 1 << 2;
//! [2]
//! [3]
// Create series and add sets to it
//![2]
//![3]
QStackedBarSeries* series = new QStackedBarSeries(categories);
series->addBarSet(set0);
series->addBarSet(set1);
series->addBarSet(set2);
series->addBarSet(set3);
series->addBarSet(set4);
//! [3]
//! [4]
// Enable tooltip
series->setToolTipEnabled();
// Connect clicked signal of set to toggle floating values of set.
QObject::connect(set0,SIGNAL(clicked(QString)),set0,SIGNAL(toggleFloatingValues()));
QObject::connect(set1,SIGNAL(clicked(QString)),set1,SIGNAL(toggleFloatingValues()));
QObject::connect(set2,SIGNAL(clicked(QString)),set2,SIGNAL(toggleFloatingValues()));
QObject::connect(set3,SIGNAL(clicked(QString)),set3,SIGNAL(toggleFloatingValues()));
QObject::connect(set4,SIGNAL(clicked(QString)),set4,SIGNAL(toggleFloatingValues()));
//! [4]
//! [5]
// Create view for chart and add series to it. Apply theme.
QChartView* chartView = new QChartView(&window);
chartView->addSeries(series);
chartView->setChartTitle("simple stacked barchart");
chartView->setChartTheme(QChart::ChartThemeIcy);
//! [5]
//! [6]
chartView->axisX()->setGridLineVisible(false);
//! [6]
//![3]
//![4]
QChart* chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple stackedbarchart example");
//![4]
//![5]
QChartView* chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![5]
//![6]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![6]
return a.exec();
}

View File

@ -2,8 +2,4 @@
error( "Couldn't find the examples.pri file!" )
}
TARGET = stackedbarchart
SOURCES += main.cpp \
chartwidget.cpp
HEADERS += \
chartwidget.h
SOURCES += main.cpp

View File

@ -1,6 +1,6 @@
#include "chartwidget.h"
ChartWidget::ChartWidget(QWidget *parent) :
ChartView::ChartView(QWidget *parent) :
QChartView(parent)
{
}

View File

@ -6,11 +6,11 @@
QTCOMMERCIALCHART_USE_NAMESPACE
class ChartWidget : public QChartView
class ChartView : public QChartView
{
Q_OBJECT
public:
explicit ChartWidget(QWidget *parent = 0);
explicit ChartView(QWidget *parent = 0);
signals:

View File

@ -1,74 +0,0 @@
#include "chartwidget.h"
#include <QMouseEvent>
ChartWidget::ChartWidget(QWidget *parent)
: QChartView(parent),
m_rubberBand(QRubberBand::Rectangle,this)
{
}
void ChartWidget::mousePressEvent(QMouseEvent *event)
{
if(event->button()!=Qt::LeftButton) return;
int margin = 25;
QRect rect(margin,margin,width()-2*margin,height()-2*margin);
m_origin = event->pos();
if (!rect.contains(m_origin)) return;
m_rubberBand.setGeometry(QRect(m_origin, QSize()));
m_rubberBand.show();
event->accept();
}
void ChartWidget::mouseMoveEvent(QMouseEvent *event)
{
if(m_rubberBand.isVisible())
m_rubberBand.setGeometry(QRect(m_origin, event->pos()).normalized());
}
void ChartWidget::mouseReleaseEvent(QMouseEvent *event)
{
if( event->button()==Qt::LeftButton && m_rubberBand.isVisible()) {
m_rubberBand.hide();
QRect rect = m_rubberBand.geometry();
zoomIn(rect);
event->accept();
}
if(event->button()==Qt::RightButton) {
zoomOut();
}
}
void ChartWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Plus:
zoomIn();
break;
case Qt::Key_Minus:
zoomOut();
break;
case Qt::Key_Left:
scrollLeft();
break;
case Qt::Key_Right:
scrollRight();
break;
case Qt::Key_Up:
scrollUp();
break;
case Qt::Key_Down:
scrollDown();
break;
default:
QGraphicsView::keyPressEvent(event);
break;
}
}

View File

@ -1,28 +0,0 @@
#ifndef CHARTWIDGET_H
#define CHARTWIDGET_H
#include <qchartview.h>
#include <QRubberBand>
QTCOMMERCIALCHART_USE_NAMESPACE
class ChartWidget : public QChartView
{
Q_OBJECT
public:
ChartWidget(QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
private:
bool rubberBandIsShown;
QRubberBand m_rubberBand;
QPoint m_origin;
};
#endif

View File

@ -1,45 +1,87 @@
#include "chartwidget.h"
/****************************************************************************
**
** Copyright (C) 2012 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 Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia nor the names of its contributors
** may be used to endorse or promote products derived from this
** software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
****************************************************************************/
#include "chartview.h"
#include <QApplication>
#include <QMainWindow>
#include <QLineSeries>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
#define PI 3.14159265358979
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
//![1]
QLineSeries* series0 = new QLineSeries();
QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
QLineSeries* series1 = new QLineSeries();
QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
//![1]
//![2]
*series0 << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10, 5);
*series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
//![2]
//![3]
QChart* chart = new QChart();
int numPoints = 100;
for (int x = 0; x <= numPoints; ++x) {
series0->add(x, fabs(sin(PI/50*x)*100));
series1->add(x, fabs(cos(PI/50*x)*100));
}
ChartWidget* chartWidget = new ChartWidget(&window);
chartWidget->setRenderHint(QPainter::Antialiasing);
chartWidget->setChartTitle("Zoom in/out line chart example");
chartWidget->setAnimationOptions(QChart::AllAnimations);
chartWidget->addSeries(series0);
chartWidget->addSeries(series1);
window.setCentralWidget(chartWidget);
window.resize(400, 300);
window.show();
chart->addSeries(series0);
chart->addSeries(series1);
chart->setTitle("Zoom in/out chart example");
chart->setAnimationOptions(QChart::AllAnimations);
//![3]
//![4]
ChartView* chartView = new ChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//![4]
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
//![5]
return a.exec();
}

View File

@ -2,8 +2,8 @@
error( "Couldn't find the examples.pri file!" )
}
TARGET = zoomlinechart
HEADERS += chartwidget.h
SOURCES += main.cpp chartwidget.cpp
HEADERS += chartview.h
SOURCES += main.cpp chartview.cpp