summaryrefslogtreecommitdiffstats
path: root/examples/charts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts')
-rw-r--r--examples/charts/areachart/areachart.pro5
-rw-r--r--examples/charts/areachart/main.cpp81
-rw-r--r--examples/charts/audio/audio.pro15
-rw-r--r--examples/charts/audio/main.cpp31
-rw-r--r--examples/charts/audio/widget.cpp82
-rw-r--r--examples/charts/audio/widget.h52
-rw-r--r--examples/charts/audio/xyseriesiodevice.cpp57
-rw-r--r--examples/charts/audio/xyseriesiodevice.h47
-rw-r--r--examples/charts/barchart/barchart.pro6
-rw-r--r--examples/charts/barchart/main.cpp93
-rw-r--r--examples/charts/barmodelmapper/barmodelmapper.pro16
-rw-r--r--examples/charts/barmodelmapper/customtablemodel.cpp107
-rw-r--r--examples/charts/barmodelmapper/customtablemodel.h51
-rw-r--r--examples/charts/barmodelmapper/main.cpp30
-rw-r--r--examples/charts/barmodelmapper/tablewidget.cpp112
-rw-r--r--examples/charts/barmodelmapper/tablewidget.h34
-rw-r--r--examples/charts/boxplotchart/acme_data.txt13
-rw-r--r--examples/charts/boxplotchart/boxdatareader.cpp79
-rw-r--r--examples/charts/boxplotchart/boxdatareader.h43
-rw-r--r--examples/charts/boxplotchart/boxplotchart.pro13
-rw-r--r--examples/charts/boxplotchart/boxplotdata.qrc6
-rw-r--r--examples/charts/boxplotchart/boxwhisk_data.txt13
-rw-r--r--examples/charts/boxplotchart/main.cpp105
-rw-r--r--examples/charts/callout/callout.cpp119
-rw-r--r--examples/charts/callout/callout.h52
-rw-r--r--examples/charts/callout/callout.pro15
-rw-r--r--examples/charts/callout/main.cpp31
-rw-r--r--examples/charts/callout/view.cpp123
-rw-r--r--examples/charts/callout/view.h59
-rw-r--r--examples/charts/chartinteractions/chart.cpp101
-rw-r--r--examples/charts/chartinteractions/chart.h53
-rw-r--r--examples/charts/chartinteractions/chartinteractions.pro11
-rw-r--r--examples/charts/chartinteractions/chartview.cpp50
-rw-r--r--examples/charts/chartinteractions/chartview.h45
-rw-r--r--examples/charts/chartinteractions/main.cpp74
-rw-r--r--examples/charts/charts.pro60
-rw-r--r--examples/charts/chartthemes/chartthemes.pro7
-rw-r--r--examples/charts/chartthemes/main.cpp35
-rw-r--r--examples/charts/chartthemes/themewidget.cpp372
-rw-r--r--examples/charts/chartthemes/themewidget.h77
-rw-r--r--examples/charts/customchart/customchart.pro6
-rw-r--r--examples/charts/customchart/main.cpp131
-rw-r--r--examples/charts/datetimeaxis/datetimeaxis.pro8
-rw-r--r--examples/charts/datetimeaxis/main.cpp100
-rw-r--r--examples/charts/datetimeaxis/sun_spots.txt284
-rw-r--r--examples/charts/datetimeaxis/sundata.qrc5
-rw-r--r--examples/charts/donutbreakdown/donutbreakdown.pro12
-rw-r--r--examples/charts/donutbreakdown/donutbreakdownchart.cpp110
-rw-r--r--examples/charts/donutbreakdown/donutbreakdownchart.h42
-rw-r--r--examples/charts/donutbreakdown/main.cpp77
-rw-r--r--examples/charts/donutbreakdown/mainslice.cpp57
-rw-r--r--examples/charts/donutbreakdown/mainslice.h48
-rw-r--r--examples/charts/donutchart/donutchart.pro5
-rw-r--r--examples/charts/donutchart/main.cpp62
-rw-r--r--examples/charts/dynamicspline/chart.cpp72
-rw-r--r--examples/charts/dynamicspline/chart.h56
-rw-r--r--examples/charts/dynamicspline/dynamicspline.pro7
-rw-r--r--examples/charts/dynamicspline/main.cpp42
-rw-r--r--examples/charts/examples.pri17
-rw-r--r--examples/charts/horizontalbarchart/horizontalbarchart.pro6
-rw-r--r--examples/charts/horizontalbarchart/main.cpp96
-rw-r--r--examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro6
-rw-r--r--examples/charts/horizontalpercentbarchart/main.cpp94
-rw-r--r--examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro6
-rw-r--r--examples/charts/horizontalstackedbarchart/main.cpp94
-rw-r--r--examples/charts/legend/legend.pro10
-rw-r--r--examples/charts/legend/main.cpp37
-rw-r--r--examples/charts/legend/mainwidget.cpp247
-rw-r--r--examples/charts/legend/mainwidget.h78
-rw-r--r--examples/charts/legendmarkers/legendmarkers.pro10
-rw-r--r--examples/charts/legendmarkers/main.cpp35
-rw-r--r--examples/charts/legendmarkers/mainwidget.cpp177
-rw-r--r--examples/charts/legendmarkers/mainwidget.h62
-rw-r--r--examples/charts/lineandbar/lineandbar.pro6
-rw-r--r--examples/charts/lineandbar/main.cpp111
-rw-r--r--examples/charts/linechart/linechart.pro5
-rw-r--r--examples/charts/linechart/main.cpp67
-rw-r--r--examples/charts/logvalueaxis/logvalueaxis.pro5
-rw-r--r--examples/charts/logvalueaxis/main.cpp75
-rw-r--r--examples/charts/modeldata/customtablemodel.cpp110
-rw-r--r--examples/charts/modeldata/customtablemodel.h51
-rw-r--r--examples/charts/modeldata/main.cpp30
-rw-r--r--examples/charts/modeldata/modeldata.pro16
-rw-r--r--examples/charts/modeldata/tablewidget.cpp112
-rw-r--r--examples/charts/modeldata/tablewidget.h34
-rw-r--r--examples/charts/multiaxis/main.cpp92
-rw-r--r--examples/charts/multiaxis/multiaxis.pro5
-rw-r--r--examples/charts/nesteddonuts/main.cpp29
-rw-r--r--examples/charts/nesteddonuts/nesteddonuts.pro8
-rw-r--r--examples/charts/nesteddonuts/widget.cpp128
-rw-r--r--examples/charts/nesteddonuts/widget.h47
-rw-r--r--examples/charts/percentbarchart/main.cpp93
-rw-r--r--examples/charts/percentbarchart/percentbarchart.pro6
-rw-r--r--examples/charts/piechart/main.cpp70
-rw-r--r--examples/charts/piechart/piechart.pro5
-rw-r--r--examples/charts/piechartcustomization/brushtool.cpp100
-rw-r--r--examples/charts/piechartcustomization/brushtool.h53
-rw-r--r--examples/charts/piechartcustomization/customslice.cpp48
-rw-r--r--examples/charts/piechartcustomization/customslice.h44
-rw-r--r--examples/charts/piechartcustomization/main.cpp34
-rw-r--r--examples/charts/piechartcustomization/mainwidget.cpp360
-rw-r--r--examples/charts/piechartcustomization/mainwidget.h93
-rw-r--r--examples/charts/piechartcustomization/pentool.cpp141
-rw-r--r--examples/charts/piechartcustomization/pentool.h60
-rw-r--r--examples/charts/piechartcustomization/piechartcustomization.pro16
-rw-r--r--examples/charts/piechartdrilldown/drilldownchart.cpp54
-rw-r--r--examples/charts/piechartdrilldown/drilldownchart.h47
-rw-r--r--examples/charts/piechartdrilldown/drilldownslice.cpp63
-rw-r--r--examples/charts/piechartdrilldown/drilldownslice.h49
-rw-r--r--examples/charts/piechartdrilldown/main.cpp77
-rw-r--r--examples/charts/piechartdrilldown/piechartdrilldown.pro11
-rw-r--r--examples/charts/polarchart/chartview.cpp111
-rw-r--r--examples/charts/polarchart/chartview.h41
-rw-r--r--examples/charts/polarchart/main.cpp137
-rw-r--r--examples/charts/polarchart/polarchart.pro6
-rw-r--r--examples/charts/qmlaxes/main.cpp50
-rw-r--r--examples/charts/qmlaxes/qml/qmlaxes/View1.qml68
-rw-r--r--examples/charts/qmlaxes/qml/qmlaxes/View2.qml60
-rw-r--r--examples/charts/qmlaxes/qml/qmlaxes/View3.qml68
-rw-r--r--examples/charts/qmlaxes/qml/qmlaxes/main.qml80
-rw-r--r--examples/charts/qmlaxes/qmlaxes.pro7
-rw-r--r--examples/charts/qmlaxes/resources.qrc8
-rw-r--r--examples/charts/qmlboxplot/main.cpp50
-rw-r--r--examples/charts/qmlboxplot/qml/qmlboxplot/main.qml41
-rw-r--r--examples/charts/qmlboxplot/qmlboxplot.pro9
-rw-r--r--examples/charts/qmlboxplot/resources.qrc5
-rw-r--r--examples/charts/qmlchart/main.cpp50
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View1.qml54
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View10.qml42
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View11.qml43
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View12.qml77
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View2.qml45
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View3.qml45
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View4.qml108
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View5.qml56
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View6.qml43
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View7.qml43
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View8.qml42
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/View9.qml43
-rw-r--r--examples/charts/qmlchart/qml/qmlchart/main.qml91
-rw-r--r--examples/charts/qmlchart/qmlchart.pro7
-rw-r--r--examples/charts/qmlchart/resources.qrc17
-rw-r--r--examples/charts/qmlcustomizations/main.cpp49
-rw-r--r--examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml102
-rw-r--r--examples/charts/qmlcustomizations/qmlcustomizations.pro7
-rw-r--r--examples/charts/qmlcustomizations/resources.qrc5
-rw-r--r--examples/charts/qmlcustomlegend/main.cpp49
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml30
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml77
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml100
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml117
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml136
-rw-r--r--examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml66
-rw-r--r--examples/charts/qmlcustomlegend/qmlcustomlegend.pro7
-rw-r--r--examples/charts/qmlcustomlegend/resources.qrc10
-rw-r--r--examples/charts/qmlf1legends/main.cpp49
-rw-r--r--examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml95
-rw-r--r--examples/charts/qmlf1legends/qml/qmlf1legends/main.qml95
-rw-r--r--examples/charts/qmlf1legends/qmlf1legends.pro7
-rw-r--r--examples/charts/qmlf1legends/resources.qrc6
-rw-r--r--examples/charts/qmloscilloscope/datasource.cpp91
-rw-r--r--examples/charts/qmloscilloscope/datasource.h49
-rw-r--r--examples/charts/qmloscilloscope/main.cpp56
-rw-r--r--examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml88
-rw-r--r--examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml60
-rw-r--r--examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml115
-rw-r--r--examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml61
-rw-r--r--examples/charts/qmloscilloscope/qmloscilloscope.pro11
-rw-r--r--examples/charts/qmloscilloscope/resources.qrc8
-rw-r--r--examples/charts/qmlpiechart/main.cpp49
-rw-r--r--examples/charts/qmlpiechart/qml/qmlpiechart/main.qml54
-rw-r--r--examples/charts/qmlpiechart/qmlpiechart.pro7
-rw-r--r--examples/charts/qmlpiechart/qmlpiechart.svg93
-rw-r--r--examples/charts/qmlpiechart/resources.qrc5
-rw-r--r--examples/charts/qmlpolarchart/main.cpp49
-rw-r--r--examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml69
-rw-r--r--examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml90
-rw-r--r--examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml77
-rw-r--r--examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml80
-rw-r--r--examples/charts/qmlpolarchart/qmlpolarchart.pro7
-rw-r--r--examples/charts/qmlpolarchart/resources.qrc8
-rw-r--r--examples/charts/qmlweather/main.cpp59
-rw-r--r--examples/charts/qmlweather/qml/qmlweather/main.qml201
-rw-r--r--examples/charts/qmlweather/qmlweather.pro7
-rw-r--r--examples/charts/qmlweather/resources.qrc5
-rw-r--r--examples/charts/scatterchart/chartview.cpp98
-rw-r--r--examples/charts/scatterchart/chartview.h35
-rw-r--r--examples/charts/scatterchart/main.cpp40
-rw-r--r--examples/charts/scatterchart/scatterchart.pro9
-rw-r--r--examples/charts/scatterinteractions/chartview.cpp79
-rw-r--r--examples/charts/scatterinteractions/chartview.h46
-rw-r--r--examples/charts/scatterinteractions/main.cpp35
-rw-r--r--examples/charts/scatterinteractions/scatterinteractions.pro9
-rw-r--r--examples/charts/splinechart/main.cpp68
-rw-r--r--examples/charts/splinechart/splinechart.pro5
-rw-r--r--examples/charts/stackedbarchart/main.cpp93
-rw-r--r--examples/charts/stackedbarchart/stackedbarchart.pro5
-rw-r--r--examples/charts/stackedbarchartdrilldown/drilldownchart.cpp60
-rw-r--r--examples/charts/stackedbarchartdrilldown/drilldownchart.h46
-rw-r--r--examples/charts/stackedbarchartdrilldown/drilldownseries.cpp46
-rw-r--r--examples/charts/stackedbarchartdrilldown/drilldownseries.h48
-rw-r--r--examples/charts/stackedbarchartdrilldown/main.cpp113
-rw-r--r--examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro6
-rw-r--r--examples/charts/temperaturerecords/main.cpp88
-rw-r--r--examples/charts/temperaturerecords/temperaturerecords.pro6
-rw-r--r--examples/charts/zoomlinechart/chart.cpp63
-rw-r--r--examples/charts/zoomlinechart/chart.h48
-rw-r--r--examples/charts/zoomlinechart/chartview.cpp100
-rw-r--r--examples/charts/zoomlinechart/chartview.h49
-rw-r--r--examples/charts/zoomlinechart/main.cpp62
-rw-r--r--examples/charts/zoomlinechart/zoomlinechart.pro7
211 files changed, 12046 insertions, 0 deletions
diff --git a/examples/charts/areachart/areachart.pro b/examples/charts/areachart/areachart.pro
new file mode 100644
index 00000000..e8e1a074
--- /dev/null
+++ b/examples/charts/areachart/areachart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = areachart
+SOURCES += main.cpp
diff --git a/examples/charts/areachart/main.cpp b/examples/charts/areachart/main.cpp
new file mode 100644
index 00000000..6f2a1cac
--- /dev/null
+++ b/examples/charts/areachart/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** 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 <QtCharts/QChartView>
+#include <QtCharts/QLineSeries>
+#include <QtCharts/QAreaSeries>
+
+QT_CHARTS_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);
+//![2]
+
+//![3]
+ QAreaSeries *series = new QAreaSeries(series0, series1);
+ series->setName("Batman");
+ QPen pen(0x059605);
+ pen.setWidth(3);
+ series->setPen(pen);
+
+ QLinearGradient gradient(QPointF(0, 0), QPointF(0, 1));
+ gradient.setColorAt(0.0, 0x3cc63c);
+ gradient.setColorAt(1.0, 0x26f626);
+ gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
+ series->setBrush(gradient);
+//![3]
+
+//![4]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple areachart example");
+ chart->createDefaultAxes();
+ 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();
+//![6]
+
+ return a.exec();
+}
diff --git a/examples/charts/audio/audio.pro b/examples/charts/audio/audio.pro
new file mode 100644
index 00000000..6a3b6917
--- /dev/null
+++ b/examples/charts/audio/audio.pro
@@ -0,0 +1,15 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += multimedia
+
+TARGET = audio
+TEMPLATE = app
+
+SOURCES += main.cpp\
+ widget.cpp \
+ xyseriesiodevice.cpp
+
+HEADERS += widget.h \
+ xyseriesiodevice.h
diff --git a/examples/charts/audio/main.cpp b/examples/charts/audio/main.cpp
new file mode 100644
index 00000000..dd9069df
--- /dev/null
+++ b/examples/charts/audio/main.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** 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 "widget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/audio/widget.cpp b/examples/charts/audio/widget.cpp
new file mode 100644
index 00000000..6cd5d442
--- /dev/null
+++ b/examples/charts/audio/widget.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 "widget.h"
+#include <QAudioDeviceInfo>
+#include <QAudioInput>
+#include <QChartView>
+#include <QLineSeries>
+#include <QChart>
+#include <QVBoxLayout>
+#include <QValueAxis>
+#include "xyseriesiodevice.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent),
+ m_device(0),
+ m_chart(0),
+ m_series(0),
+ m_audioInput(0)
+{
+ m_chart = new QChart;
+ QChartView *chartView = new QChartView(m_chart);
+ chartView->setMinimumSize(800, 600);
+ m_series = new QLineSeries;
+ m_chart->addSeries(m_series);
+ QValueAxis *axisX = new QValueAxis;
+ axisX->setRange(0, 2000);
+ axisX->setLabelFormat("%g");
+ axisX->setTitleText("Samples");
+ QValueAxis *axisY = new QValueAxis;
+ axisY->setRange(-1, 1);
+ axisY->setTitleText("Audio level");
+ m_chart->setAxisX(axisX, m_series);
+ m_chart->setAxisY(axisY, m_series);
+ m_chart->legend()->hide();
+ m_chart->setTitle("Data from the microphone");
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(chartView);
+ setLayout(mainLayout);
+
+ QAudioFormat formatAudio;
+ formatAudio.setSampleRate(8000);
+ formatAudio.setChannelCount(1);
+ formatAudio.setSampleSize(8);
+ formatAudio.setCodec("audio/pcm");
+ formatAudio.setByteOrder(QAudioFormat::LittleEndian);
+ formatAudio.setSampleType(QAudioFormat::UnSignedInt);
+
+ QAudioDeviceInfo inputDevices = QAudioDeviceInfo::defaultInputDevice();
+ m_audioInput = new QAudioInput(inputDevices,formatAudio, this);
+
+ m_device = new XYSeriesIODevice(m_series, this);
+ m_device->open(QIODevice::WriteOnly);
+
+ m_audioInput->start(m_device);
+}
+
+Widget::~Widget()
+{
+ m_audioInput->stop();
+ m_device->close();
+}
diff --git a/examples/charts/audio/widget.h b/examples/charts/audio/widget.h
new file mode 100644
index 00000000..6f745069
--- /dev/null
+++ b/examples/charts/audio/widget.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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 WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+#include <QChartGlobal>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QLineSeries;
+class QChart;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+class XYSeriesIODevice;
+class QAudioInput;
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = 0);
+ ~Widget();
+
+private:
+ XYSeriesIODevice *m_device;
+ QChart *m_chart;
+ QLineSeries *m_series;
+ QAudioInput *m_audioInput;
+};
+
+#endif // WIDGET_H
diff --git a/examples/charts/audio/xyseriesiodevice.cpp b/examples/charts/audio/xyseriesiodevice.cpp
new file mode 100644
index 00000000..5440771f
--- /dev/null
+++ b/examples/charts/audio/xyseriesiodevice.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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 "xyseriesiodevice.h"
+#include <QXYSeries>
+
+XYSeriesIODevice::XYSeriesIODevice(QXYSeries * series, QObject *parent) :
+ QIODevice(parent),
+ m_series(series)
+{
+}
+
+qint64 XYSeriesIODevice::readData(char * data, qint64 maxSize)
+{
+ Q_UNUSED(data)
+ Q_UNUSED(maxSize)
+ return -1;
+}
+
+qint64 XYSeriesIODevice::writeData(const char * data, qint64 maxSize)
+{
+ qint64 range = 2000;
+ QList<QPointF> oldPoints = m_series->points();
+ QList<QPointF> points;
+ int resolution = 4;
+
+ if (oldPoints.count() < range) {
+ points = m_series->points();
+ } else {
+ for (int i = maxSize/resolution; i < oldPoints.count(); i++)
+ points.append(QPointF(i - maxSize/resolution, oldPoints.at(i).y()));
+ }
+
+ qint64 size = points.count();
+ for (int k = 0; k < maxSize/resolution; k++)
+ points.append(QPointF(k + size, ((quint8)data[resolution * k] - 128)/128.0));
+
+ m_series->replace(points);
+ return maxSize;
+}
diff --git a/examples/charts/audio/xyseriesiodevice.h b/examples/charts/audio/xyseriesiodevice.h
new file mode 100644
index 00000000..6e504b08
--- /dev/null
+++ b/examples/charts/audio/xyseriesiodevice.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** 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 XYSERIESIODEVICE_H
+#define XYSERIESIODEVICE_H
+
+#include <QIODevice>
+#include <QChartGlobal>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QXYSeries;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+class XYSeriesIODevice : public QIODevice
+{
+ Q_OBJECT
+public:
+ explicit XYSeriesIODevice(QXYSeries * series, QObject *parent = 0);
+
+protected:
+ qint64 readData(char * data, qint64 maxSize);
+ qint64 writeData(const char * data, qint64 maxSize);
+
+private:
+ QXYSeries *m_series;
+};
+
+#endif // XYSERIESIODEVICE_H
diff --git a/examples/charts/barchart/barchart.pro b/examples/charts/barchart/barchart.pro
new file mode 100644
index 00000000..14db3c88
--- /dev/null
+++ b/examples/charts/barchart/barchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = barchart
+SOURCES += main.cpp
diff --git a/examples/charts/barchart/main.cpp b/examples/charts/barchart/main.cpp
new file mode 100644
index 00000000..a0e3cd89
--- /dev/null
+++ b/examples/charts/barchart/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QBarSeries *series = new QBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple barchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisX(axis, series);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/barmodelmapper/barmodelmapper.pro b/examples/charts/barmodelmapper/barmodelmapper.pro
new file mode 100644
index 00000000..91b8f367
--- /dev/null
+++ b/examples/charts/barmodelmapper/barmodelmapper.pro
@@ -0,0 +1,16 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += core gui
+
+TARGET = barmodelmapper
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ tablewidget.cpp \
+ customtablemodel.cpp
+
+HEADERS += tablewidget.h \
+ customtablemodel.h
diff --git a/examples/charts/barmodelmapper/customtablemodel.cpp b/examples/charts/barmodelmapper/customtablemodel.cpp
new file mode 100644
index 00000000..3ec58384
--- /dev/null
+++ b/examples/charts/barmodelmapper/customtablemodel.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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 "customtablemodel.h"
+#include <QVector>
+#include <QTime>
+#include <QRect>
+#include <QColor>
+
+CustomTableModel::CustomTableModel(QObject *parent) :
+ QAbstractTableModel(parent)
+{
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ m_columnCount = 6;
+ m_rowCount = 12;
+
+ // m_data
+ for (int i = 0; i < m_rowCount; i++) {
+ QVector<qreal>* dataVec = new QVector<qreal>(m_columnCount);
+ for (int k = 0; k < dataVec->size(); k++) {
+ if (k % 2 == 0)
+ dataVec->replace(k, i * 50 + qrand() % 20);
+ else
+ dataVec->replace(k, qrand() % 100);
+ }
+ m_data.append(dataVec);
+ }
+}
+
+int CustomTableModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_data.count();
+}
+
+int CustomTableModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_columnCount;
+}
+
+QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("201%1").arg(section);
+ else
+ return QString("%1").arg(section + 1);
+}
+
+QVariant CustomTableModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::DisplayRole) {
+ return m_data[index.row()]->at(index.column());
+ } else if (role == Qt::EditRole) {
+ return m_data[index.row()]->at(index.column());
+ } else if (role == Qt::BackgroundRole) {
+ QRect rect;
+ foreach (rect, m_mapping)
+ if (rect.contains(index.column(), index.row()))
+ return QColor(m_mapping.key(rect));
+
+ // cell not mapped return white color
+ return QColor(Qt::white);
+ }
+ return QVariant();
+}
+
+bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+ m_data[index.row()]->replace(index.column(), value.toDouble());
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const
+{
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+
+void CustomTableModel::addMapping(QString color, QRect area)
+{
+ m_mapping.insertMulti(color, area);
+}
diff --git a/examples/charts/barmodelmapper/customtablemodel.h b/examples/charts/barmodelmapper/customtablemodel.h
new file mode 100644
index 00000000..755f4c7d
--- /dev/null
+++ b/examples/charts/barmodelmapper/customtablemodel.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 CUSTOMTABLEMODEL_H
+#define CUSTOMTABLEMODEL_H
+
+#include <QAbstractTableModel>
+#include <QHash>
+#include <QRect>
+
+class CustomTableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit CustomTableModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void addMapping(QString color, QRect area);
+ void clearMapping() { m_mapping.clear(); }
+
+private:
+ QList<QVector<qreal> * > m_data;
+ QHash<QString, QRect> m_mapping;
+ int m_columnCount;
+ int m_rowCount;
+};
+
+#endif // CUSTOMTABLEMODEL_H
diff --git a/examples/charts/barmodelmapper/main.cpp b/examples/charts/barmodelmapper/main.cpp
new file mode 100644
index 00000000..bf0b384b
--- /dev/null
+++ b/examples/charts/barmodelmapper/main.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** 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 "tablewidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ TableWidget w;
+ w.show();
+ return a.exec();
+}
diff --git a/examples/charts/barmodelmapper/tablewidget.cpp b/examples/charts/barmodelmapper/tablewidget.cpp
new file mode 100644
index 00000000..81e881e9
--- /dev/null
+++ b/examples/charts/barmodelmapper/tablewidget.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 "tablewidget.h"
+#include "customtablemodel.h"
+#include <QGridLayout>
+#include <QTableView>
+#include <QChart>
+#include <QChartView>
+#include <QLineSeries>
+#include <QVXYModelMapper>
+#include <QBarSeries>
+#include <QBarSet>
+#include <QVBarModelMapper>
+#include <QHeaderView>
+#include <QBarCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+TableWidget::TableWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ // create simple model for storing data
+ // user's table data model
+ //! [1]
+ CustomTableModel *model = new CustomTableModel;
+ //! [1]
+
+ //! [2]
+ // create table view and add model to it
+ QTableView *tableView = new QTableView;
+ tableView->setModel(model);
+ tableView->setMinimumWidth(300);
+ tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ //! [2]
+
+ //! [3]
+ QChart *chart = new QChart;
+ chart->setAnimationOptions(QChart::AllAnimations);
+ //! [3]
+
+ // series 1
+ //! [4]
+ QBarSeries *series = new QBarSeries;
+
+ int first = 3;
+ int count = 5;
+ QVBarModelMapper *mapper = new QVBarModelMapper(this);
+ mapper->setFirstBarSetColumn(1);
+ mapper->setLastBarSetColumn(4);
+ mapper->setFirstRow(first);
+ mapper->setRowCount(count);
+ mapper->setSeries(series);
+ mapper->setModel(model);
+ chart->addSeries(series);
+ //! [4]
+
+ //! [5]
+ // for storing color hex from the series
+ QString seriesColorHex = "#000000";
+
+ // get the color of the series and use it for showing the mapped area
+ QList<QBarSet *> barsets = series->barSets();
+ for (int i = 0; i < barsets.count(); i++) {
+ seriesColorHex = "#" + QString::number(barsets.at(i)->brush().color().rgb(), 16).right(6).toUpper();
+ model->addMapping(seriesColorHex, QRect(1 + i, first, 1, barsets.at(i)->count()));
+ }
+ //! [5]
+
+ //! [6]
+ QStringList categories;
+ categories << "April" << "May" << "June" << "July" << "August";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisX(axis, series);
+ //! [6]
+
+ //! [7]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ chartView->setMinimumSize(640, 480);
+ //! [7]
+
+ //! [8]
+ // create main layout
+ QGridLayout *mainLayout = new QGridLayout;
+ mainLayout->addWidget(tableView, 1, 0);
+ mainLayout->addWidget(chartView, 1, 1);
+ mainLayout->setColumnStretch(1, 1);
+ mainLayout->setColumnStretch(0, 0);
+ setLayout(mainLayout);
+ //! [8]
+}
diff --git a/examples/charts/barmodelmapper/tablewidget.h b/examples/charts/barmodelmapper/tablewidget.h
new file mode 100644
index 00000000..3846cc11
--- /dev/null
+++ b/examples/charts/barmodelmapper/tablewidget.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** 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 TABLEWIDGET_H
+#define TABLEWIDGET_H
+
+#include <QWidget>
+
+class TableWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TableWidget(QWidget *parent = 0);
+};
+
+#endif // TABLEWIDGET_H
diff --git a/examples/charts/boxplotchart/acme_data.txt b/examples/charts/boxplotchart/acme_data.txt
new file mode 100644
index 00000000..9511418d
--- /dev/null
+++ b/examples/charts/boxplotchart/acme_data.txt
@@ -0,0 +1,13 @@
+# 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/charts/boxplotchart/boxdatareader.cpp b/examples/charts/boxplotchart/boxdatareader.cpp
new file mode 100644
index 00000000..ba2d8b3a
--- /dev/null
+++ b/examples/charts/boxplotchart/boxdatareader.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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/charts/boxplotchart/boxdatareader.h b/examples/charts/boxplotchart/boxdatareader.h
new file mode 100644
index 00000000..5dbddc14
--- /dev/null
+++ b/examples/charts/boxplotchart/boxdatareader.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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>
+
+QT_CHARTS_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/charts/boxplotchart/boxplotchart.pro b/examples/charts/boxplotchart/boxplotchart.pro
new file mode 100644
index 00000000..c2483511
--- /dev/null
+++ b/examples/charts/boxplotchart/boxplotchart.pro
@@ -0,0 +1,13 @@
+!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/charts/boxplotchart/boxplotdata.qrc b/examples/charts/boxplotchart/boxplotdata.qrc
new file mode 100644
index 00000000..fe6d52b5
--- /dev/null
+++ b/examples/charts/boxplotchart/boxplotdata.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="acme">acme_data.txt</file>
+ <file alias="boxwhisk">boxwhisk_data.txt</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/boxplotchart/boxwhisk_data.txt b/examples/charts/boxplotchart/boxwhisk_data.txt
new file mode 100644
index 00000000..f1d49cf0
--- /dev/null
+++ b/examples/charts/boxplotchart/boxwhisk_data.txt
@@ -0,0 +1,13 @@
+# 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/charts/boxplotchart/main.cpp b/examples/charts/boxplotchart/main.cpp
new file mode 100644
index 00000000..802217e1
--- /dev/null
+++ b/examples/charts/boxplotchart/main.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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"
+
+QT_CHARTS_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();
+}
+
diff --git a/examples/charts/callout/callout.cpp b/examples/charts/callout/callout.cpp
new file mode 100644
index 00000000..2491368f
--- /dev/null
+++ b/examples/charts/callout/callout.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** 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 "callout.h"
+#include <QPainter>
+#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
+#include <QMouseEvent>
+
+Callout::Callout(QGraphicsItem * parent):
+ QGraphicsItem(parent)
+{
+}
+
+QRectF Callout::boundingRect() const
+{
+ QPointF anchor = mapFromParent(m_anchor);
+ QRectF rect;
+ rect.setLeft(qMin(m_rect.left(), anchor.x()));
+ rect.setRight(qMax(m_rect.right(), anchor.x()));
+ rect.setTop(qMin(m_rect.top(), anchor.y()));
+ rect.setBottom(qMax(m_rect.bottom(), anchor.y()));
+ return rect;
+}
+
+void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option)
+ Q_UNUSED(widget)
+ QPainterPath path;
+ path.addRoundedRect(m_rect, 5, 5);
+
+ QPointF anchor = mapFromParent(m_anchor);
+ if (!m_rect.contains(anchor)) {
+ QPointF point1, point2;
+
+ // establish the position of the anchor point in relation to m_rect
+ bool above = anchor.y() <= m_rect.top();
+ bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y();
+ bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom();
+ bool below = anchor.y() > m_rect.bottom();
+
+ bool onLeft = anchor.x() <= m_rect.left();
+ bool leftOfCenter = anchor.x() > m_rect.left() && anchor.x() <= m_rect.center().x();
+ bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right();
+ bool onRight = anchor.x() > m_rect.right();
+
+ // get the nearest m_rect corner.
+ qreal x = (onRight + rightOfCenter) * m_rect.width();
+ qreal y = (below + belowCenter) * m_rect.height();
+ bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight);
+ bool vertical = qAbs(anchor.x() - x) > qAbs(anchor.y() - y);
+
+ qreal x1 = x + leftOfCenter * 10 - rightOfCenter * 20 + cornerCase * !vertical * (onLeft * 10 - onRight * 20);
+ qreal y1 = y + aboveCenter * 10 - belowCenter * 20 + cornerCase * vertical * (above * 10 - below * 20);;
+ point1.setX(x1);
+ point1.setY(y1);
+
+ qreal x2 = x + leftOfCenter * 20 - rightOfCenter * 10 + cornerCase * !vertical * (onLeft * 20 - onRight * 10);;
+ qreal y2 = y + aboveCenter * 20 - belowCenter * 10 + cornerCase * vertical * (above * 20 - below * 10);;
+ point2.setX(x2);
+ point2.setY(y2);
+
+ path.moveTo(point1);
+ path.lineTo(mapFromParent(m_anchor));
+ path.lineTo(point2);
+ path = path.simplified();
+ }
+ painter->setBrush(QColor(255, 255, 255));
+ painter->drawPath(path);
+ painter->drawText(m_textRect, m_text);
+}
+
+void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ event->setAccepted(true);
+}
+
+void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->buttons() & Qt::LeftButton){
+ setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton)));
+ event->setAccepted(true);
+ } else {
+ event->setAccepted(false);
+ }
+}
+
+void Callout::setText(const QString &text)
+{
+ m_text = text;
+ QFontMetrics metrics(m_font);
+ m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text);
+ m_textRect.translate(5, 5);
+ prepareGeometryChange();
+ m_rect = m_textRect.adjusted(-5, -5, 5, 5);
+}
+
+void Callout::setAnchor(QPointF point)
+{
+ m_anchor = point;
+}
diff --git a/examples/charts/callout/callout.h b/examples/charts/callout/callout.h
new file mode 100644
index 00000000..23fc8484
--- /dev/null
+++ b/examples/charts/callout/callout.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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 CALLOUT_H
+#define CALLOUT_H
+
+#include <QGraphicsItem>
+#include <QFont>
+
+class QGraphicsSceneMouseEvent;
+
+class Callout : public QGraphicsItem
+{
+public:
+ Callout(QGraphicsItem * parent = 0);
+
+ void setText(const QString &text);
+ void setAnchor(QPointF point);
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
+
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
+private:
+ QString m_text;
+ QRectF m_textRect;
+ QRectF m_rect;
+ QPointF m_anchor;
+ QFont m_font;
+};
+
+#endif // CALLOUT_H
diff --git a/examples/charts/callout/callout.pro b/examples/charts/callout/callout.pro
new file mode 100644
index 00000000..b0da66d6
--- /dev/null
+++ b/examples/charts/callout/callout.pro
@@ -0,0 +1,15 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = callout
+TEMPLATE = app
+
+SOURCES += \
+ main.cpp\
+ callout.cpp \
+ view.cpp
+
+HEADERS += \
+ callout.h \
+ view.h
diff --git a/examples/charts/callout/main.cpp b/examples/charts/callout/main.cpp
new file mode 100644
index 00000000..a6dfc2e9
--- /dev/null
+++ b/examples/charts/callout/main.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** 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 "view.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ View w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/callout/view.cpp b/examples/charts/callout/view.cpp
new file mode 100644
index 00000000..a7c43863
--- /dev/null
+++ b/examples/charts/callout/view.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+ **
+ ** 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 "view.h"
+#include <QResizeEvent>
+#include <QGraphicsScene>
+#include <QChart>
+#include <QLineSeries>
+#include <QSplineSeries>
+#include <QGraphicsTextItem>
+#include "callout.h"
+#include <QMouseEvent>
+
+View::View(QWidget *parent)
+ : QGraphicsView(new QGraphicsScene, parent),
+ m_coordX(0),
+ m_coordY(0),
+ m_chart(0),
+ m_tooltip(0)
+{
+ setDragMode(QGraphicsView::NoDrag);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ // chart
+ m_chart = new QChart;
+ m_chart->setMinimumSize(640, 480);
+ m_chart->setTitle("Hover the line to show callout. Click the line to make it stay");
+ m_chart->legend()->hide();
+ QLineSeries *series = new QLineSeries;
+ series->append(1, 3);
+ series->append(4, 5);
+ series->append(5, 4.5);
+ series->append(7, 1);
+ series->append(11, 2);
+ m_chart->addSeries(series);
+
+ QSplineSeries *series2 = new QSplineSeries;
+ series2->append(1.6, 1.4);
+ series2->append(2.4, 3.5);
+ series2->append(3.7, 2.5);
+ series2->append(7, 4);
+ series2->append(10, 2);
+ m_chart->addSeries(series2);
+
+ m_chart->createDefaultAxes();
+ m_chart->setAcceptHoverEvents(true);
+
+ setRenderHint(QPainter::Antialiasing);
+ scene()->addItem(m_chart);
+
+ m_coordX = new QGraphicsSimpleTextItem(m_chart);
+ m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height());
+ m_coordX->setText("X: ");
+ m_coordY = new QGraphicsSimpleTextItem(m_chart);
+ m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height());
+ m_coordY->setText("Y: ");
+
+ connect(series, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout()));
+ connect(series, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool)));
+
+ connect(series2, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout()));
+ connect(series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool)));
+
+ this->setMouseTracking(true);
+}
+
+void View::resizeEvent(QResizeEvent *event)
+{
+ if (scene()) {
+ scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
+ m_chart->resize(event->size());
+ m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height() - 20);
+ m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height() - 20);
+ }
+ QGraphicsView::resizeEvent(event);
+}
+
+void View::mouseMoveEvent(QMouseEvent *event)
+{
+ m_coordX->setText(QString("X: %1").arg(m_chart->mapToValue(event->pos()).x()));
+ m_coordY->setText(QString("Y: %1").arg(m_chart->mapToValue(event->pos()).y()));
+ QGraphicsView::mouseMoveEvent(event);
+}
+
+void View::keepCallout()
+{
+ m_tooltip = new Callout(m_chart);
+}
+
+void View::tooltip(QPointF point, bool state)
+{
+ if (m_tooltip == 0)
+ m_tooltip = new Callout(m_chart);
+
+ if (state) {
+ m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y()));
+ QXYSeries *series = qobject_cast<QXYSeries *>(sender());
+ m_tooltip->setAnchor(m_chart->mapToPosition(point, series));
+ m_tooltip->setPos(m_chart->mapToPosition(point, series) + QPoint(10, -50));
+ m_tooltip->setZValue(11);
+ m_tooltip->show();
+ } else {
+ m_tooltip->hide();
+ }
+}
diff --git a/examples/charts/callout/view.h b/examples/charts/callout/view.h
new file mode 100644
index 00000000..3a322382
--- /dev/null
+++ b/examples/charts/callout/view.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** 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 VIEW_H
+#define VIEW_H
+#include <QGraphicsView>
+#include <QChartGlobal>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QChart;
+QT_CHARTS_END_NAMESPACE
+
+class QGraphicsScene;
+class QResizeEvent;
+class Callout;
+class QMouseEvent;
+
+QT_CHARTS_USE_NAMESPACE
+
+class View: public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ View(QWidget *parent = 0);
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+public slots:
+ void keepCallout();
+ void tooltip(QPointF point, bool state);
+
+private:
+ QGraphicsSimpleTextItem *m_coordX;
+ QGraphicsSimpleTextItem *m_coordY;
+ QChart *m_chart;
+ Callout *m_tooltip;
+};
+
+#endif
diff --git a/examples/charts/chartinteractions/chart.cpp b/examples/charts/chartinteractions/chart.cpp
new file mode 100644
index 00000000..8aa2a443
--- /dev/null
+++ b/examples/charts/chartinteractions/chart.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** 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 "chart.h"
+#include <QValueAxis>
+#include <QAbstractAxis>
+#include <qmath.h>
+
+Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags, QLineSeries *series)
+ : QChart(QChart::ChartTypeCartesian, parent, wFlags), m_series(series)
+{
+ m_clicked = false;
+}
+
+Chart::~Chart()
+{
+}
+
+void Chart::clickPoint(const QPointF &point)
+{
+ // Find the closes data point
+ m_movingPoint = QPoint();
+ m_clicked = false;
+ foreach (QPointF p, m_series->points()) {
+ if (distance(p, point) < distance(m_movingPoint, point)) {
+ m_movingPoint = p;
+ m_clicked = true;
+ }
+ }
+}
+
+qreal Chart::distance(const QPointF &p1, const QPointF &p2)
+{
+ return qSqrt((p1.x() - p2.x()) * (p1.x() - p2.x())
+ + (p1.y() - p2.y()) * (p1.y() - p2.y()));
+}
+
+void Chart::setPointClicked(bool clicked)
+{
+ m_clicked = clicked;
+}
+
+void Chart::handlePointMove(const QPoint &point)
+{
+ if (m_clicked) {
+ //Map the point clicked from the ChartView
+ //to the area occupied by the chart.
+ QPoint mappedPoint = point;
+ mappedPoint.setX(point.x() - this->plotArea().x());
+ mappedPoint.setY(point.y() - this->plotArea().y());
+
+ //Get the x- and y axis to be able to convert the mapped
+ //coordinate point to the charts scale.
+ QAbstractAxis *axisx = this->axisX();
+ QValueAxis *haxis = 0;
+ if (axisx->type() == QAbstractAxis::AxisTypeValue)
+ haxis = qobject_cast<QValueAxis *>(axisx);
+
+ QAbstractAxis *axisy = this->axisY();
+ QValueAxis *vaxis = 0;
+ if (axisy->type() == QAbstractAxis::AxisTypeValue)
+ vaxis = qobject_cast<QValueAxis *>(axisy);
+
+ if (haxis && vaxis) {
+ //Calculate the "unit" between points on the x
+ //y axis.
+ double xUnit = this->plotArea().width() / haxis->max();
+ double yUnit = this->plotArea().height() / vaxis->max();
+
+ //Convert the mappedPoint to the actual chart scale.
+ double x = mappedPoint.x() / xUnit;
+ double y = vaxis->max() - mappedPoint.y() / yUnit;
+
+ //Replace the old point with the new one.
+ m_series->replace(m_movingPoint, QPointF(x, y));
+
+ //Update the m_movingPoint so we are able to
+ //do the replace also during mousemoveEvent.
+ m_movingPoint.setX(x);
+ m_movingPoint.setY(y);
+ }
+ }
+}
+
diff --git a/examples/charts/chartinteractions/chart.h b/examples/charts/chartinteractions/chart.h
new file mode 100644
index 00000000..9a10387b
--- /dev/null
+++ b/examples/charts/chartinteractions/chart.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 CHART_H
+#define CHART_H
+
+#include <QChart>
+#include <QLineSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class Chart : public QChart
+{
+ Q_OBJECT
+public:
+ explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0, QLineSeries *series = 0);
+ ~Chart();
+
+public slots:
+ void clickPoint(const QPointF &point);
+
+public:
+ void handlePointMove(const QPoint &point);
+ void setPointClicked(bool clicked);
+
+private:
+ qreal distance(const QPointF &p1, const QPointF &p2);
+ QLineSeries *m_series;
+ QPointF m_movingPoint;
+
+ //Boolean value to determine if an actual point in the
+ //series is clicked.
+ bool m_clicked;
+};
+
+#endif // CHART_H
diff --git a/examples/charts/chartinteractions/chartinteractions.pro b/examples/charts/chartinteractions/chartinteractions.pro
new file mode 100644
index 00000000..8cf4c36c
--- /dev/null
+++ b/examples/charts/chartinteractions/chartinteractions.pro
@@ -0,0 +1,11 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += core gui
+
+TARGET = chartinteractions
+TEMPLATE = app
+
+HEADERS += chart.h chartview.h
+SOURCES += main.cpp chart.cpp chartview.cpp
diff --git a/examples/charts/chartinteractions/chartview.cpp b/examples/charts/chartinteractions/chartview.cpp
new file mode 100644
index 00000000..95fae6cd
--- /dev/null
+++ b/examples/charts/chartinteractions/chartview.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <QMouseEvent>
+#include "chart.h"
+
+ChartView::ChartView(Chart *chart, QWidget *parent) :
+ QChartView(chart, parent)
+{
+ m_chart = chart;
+}
+
+void ChartView::mousePressEvent(QMouseEvent *event)
+{
+ m_mousePos = event->pos();
+ QChartView::mousePressEvent(event);
+}
+
+void ChartView::mouseMoveEvent(QMouseEvent *event)
+{
+ m_chart->handlePointMove(event->pos());
+ QChartView::mouseMoveEvent(event);
+}
+
+void ChartView::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (event->pos() != m_mousePos) {
+ m_chart->handlePointMove(event->pos());
+ m_chart->setPointClicked(false);
+ }
+ QChartView::mouseReleaseEvent(event);
+}
diff --git a/examples/charts/chartinteractions/chartview.h b/examples/charts/chartinteractions/chartview.h
new file mode 100644
index 00000000..931feee0
--- /dev/null
+++ b/examples/charts/chartinteractions/chartview.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** 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 CHARTVIEW_H
+#define CHARTVIEW_H
+
+#include <QChartView>
+
+class Chart;
+
+QT_CHARTS_USE_NAMESPACE
+
+class ChartView : public QChartView
+{
+public:
+ ChartView(Chart *chart, QWidget *parent = 0);
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ Chart *m_chart;
+ QPoint m_mousePos;
+};
+
+#endif
diff --git a/examples/charts/chartinteractions/main.cpp b/examples/charts/chartinteractions/main.cpp
new file mode 100644
index 00000000..67cfb800
--- /dev/null
+++ b/examples/charts/chartinteractions/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+
+#include <QValueAxis>
+
+#include "chart.h"
+#include "chartview.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ QLineSeries *series = new QLineSeries();
+
+ series->append(0, 6);
+ series->append(1, 3);
+ series->append(2, 4);
+ series->append(3, 8);
+ series->append(7, 13);
+ series->append(10, 5);
+ *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
+
+ Chart *chart = new Chart(0, 0, series);
+ chart->legend()->hide();
+ chart->addSeries(series);
+ QPen p = series->pen();
+ p.setWidth(5);
+ series->setPen(p);
+ chart->createDefaultAxes();
+ chart->setTitle("Drag'n drop to move data points");
+
+ QValueAxis *axisX = new QValueAxis();
+ chart->setAxisX(axisX, series);
+ axisX->setRange(0, 20);
+
+ QValueAxis *axisY = new QValueAxis();
+ chart->setAxisY(axisY, series);
+ axisY->setRange(0, 13);
+
+ QObject::connect(series, SIGNAL(clicked(QPointF)), chart, SLOT(clickPoint(QPointF)));
+
+ ChartView *chartView = new ChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/charts.pro b/examples/charts/charts.pro
new file mode 100644
index 00000000..e9d3e0e8
--- /dev/null
+++ b/examples/charts/charts.pro
@@ -0,0 +1,60 @@
+TEMPLATE = subdirs
+SUBDIRS += areachart \
+ customchart \
+ linechart \
+ percentbarchart \
+ piechart \
+ piechartdrilldown \
+ scatterchart \
+ scatterinteractions \
+ splinechart \
+ stackedbarchart \
+ stackedbarchartdrilldown \
+ zoomlinechart \
+ modeldata \
+ barchart \
+ boxplotchart \
+ legend \
+ barmodelmapper \
+ lineandbar \
+ horizontalbarchart \
+ horizontalstackedbarchart \
+ horizontalpercentbarchart \
+ donutbreakdown \
+ temperaturerecords \
+ donutchart \
+ multiaxis \
+ legendmarkers \
+ logvalueaxis \
+ polarchart \
+ piechartcustomization \
+ dynamicspline \
+ nesteddonuts \
+ chartinteractions \
+ callout \
+ chartthemes
+
+qtHaveModule(quick) {
+ SUBDIRS += qmlboxplot \
+ qmlpiechart \
+ qmlweather \
+ qmlf1legends \
+ qmlcustomizations \
+ qmlaxes \
+ qmlcustomlegend \
+ qmlpolarchart \
+ qmlchart \
+ qmloscilloscope
+}
+
+contains(QT_CONFIG, multimedia) {
+ SUBDIRS += audio
+} else {
+ message("QtMultimedia library not available. Some examples are disabled")
+}
+
+!linux-arm*: {
+SUBDIRS += \
+ datetimeaxis
+}
+
diff --git a/examples/charts/chartthemes/chartthemes.pro b/examples/charts/chartthemes/chartthemes.pro
new file mode 100644
index 00000000..2a414557
--- /dev/null
+++ b/examples/charts/chartthemes/chartthemes.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = chartthemes
+SOURCES = main.cpp themewidget.cpp
+HEADERS = themewidget.h
diff --git a/examples/charts/chartthemes/main.cpp b/examples/charts/chartthemes/main.cpp
new file mode 100644
index 00000000..5bc1af84
--- /dev/null
+++ b/examples/charts/chartthemes/main.cpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** 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 "themewidget.h"
+#include <QApplication>
+#include <QMainWindow>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow window;
+ ThemeWidget *widget = new ThemeWidget();
+ window.setCentralWidget(widget);
+ window.resize(900, 600);
+ window.show();
+ return a.exec();
+}
+
diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp
new file mode 100644
index 00000000..d1b0051b
--- /dev/null
+++ b/examples/charts/chartthemes/themewidget.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+**
+** 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 "themewidget.h"
+
+#include <QChartView>
+#include <QPieSeries>
+#include <QPieSlice>
+#include <QAbstractBarSeries>
+#include <QPercentBarSeries>
+#include <QStackedBarSeries>
+#include <QBarSeries>
+#include <QBarSet>
+#include <QLineSeries>
+#include <QSplineSeries>
+#include <QScatterSeries>
+#include <QAreaSeries>
+#include <QLegend>
+#include <QGridLayout>
+#include <QFormLayout>
+#include <QComboBox>
+#include <QSpinBox>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QTime>
+#include <QBarCategoryAxis>
+
+ThemeWidget::ThemeWidget(QWidget *parent) :
+ QWidget(parent),
+ m_listCount(3),
+ m_valueMax(10),
+ m_valueCount(7),
+ m_dataTable(generateRandomData(m_listCount, m_valueMax, m_valueCount)),
+ m_themeComboBox(createThemeBox()),
+ m_antialiasCheckBox(new QCheckBox("Anti-aliasing")),
+ m_animatedComboBox(createAnimationBox()),
+ m_legendComboBox(createLegendBox())
+{
+ connectSignals();
+ // create layout
+ QGridLayout *baseLayout = new QGridLayout();
+ QHBoxLayout *settingsLayout = new QHBoxLayout();
+ settingsLayout->addWidget(new QLabel("Theme:"));
+ settingsLayout->addWidget(m_themeComboBox);
+ settingsLayout->addWidget(new QLabel("Animation:"));
+ settingsLayout->addWidget(m_animatedComboBox);
+ settingsLayout->addWidget(new QLabel("Legend:"));
+ settingsLayout->addWidget(m_legendComboBox);
+ settingsLayout->addWidget(m_antialiasCheckBox);
+ settingsLayout->addStretch();
+ baseLayout->addLayout(settingsLayout, 0, 0, 1, 3);
+
+ //create charts
+
+ QChartView *chartView;
+
+ chartView = new QChartView(createAreaChart());
+ baseLayout->addWidget(chartView, 1, 0);
+ m_charts << chartView;
+
+ chartView = new QChartView(createBarChart(m_valueCount));
+ baseLayout->addWidget(chartView, 1, 1);
+ m_charts << chartView;
+
+ chartView = new QChartView(createLineChart());
+ baseLayout->addWidget(chartView, 1, 2);
+ m_charts << chartView;
+
+ chartView = new QChartView(createPieChart());
+ chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen...
+ baseLayout->addWidget(chartView, 2, 0);
+ m_charts << chartView;
+
+ chartView = new QChartView(createSplineChart());
+ baseLayout->addWidget(chartView, 2, 1);
+ m_charts << chartView;
+
+ chartView = new QChartView(createScatterChart());
+ baseLayout->addWidget(chartView, 2, 2);
+ m_charts << chartView;
+
+ setLayout(baseLayout);
+
+ // Set defaults
+ m_antialiasCheckBox->setChecked(true);
+ updateUI();
+}
+
+ThemeWidget::~ThemeWidget()
+{
+}
+
+void ThemeWidget::connectSignals()
+{
+ connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
+ connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI()));
+ connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
+ connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()));
+}
+
+DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int valueCount) const
+{
+ DataTable dataTable;
+
+ // set seed for random stuff
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ // generate random data
+ for (int i(0); i < listCount; i++) {
+ DataList dataList;
+ qreal yValue(0);
+ for (int j(0); j < valueCount; j++) {
+ yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount;
+ QPointF value((j + (qreal) rand() / (qreal) RAND_MAX) * ((qreal) m_valueMax / (qreal) valueCount),
+ yValue);
+ QString label = "Slice " + QString::number(i) + ":" + QString::number(j);
+ dataList << Data(value, label);
+ }
+ dataTable << dataList;
+ }
+
+ return dataTable;
+}
+
+QComboBox *ThemeWidget::createThemeBox() const
+{
+ // settings layout
+ QComboBox *themeComboBox = new QComboBox();
+ themeComboBox->addItem("Light", QChart::ChartThemeLight);
+ themeComboBox->addItem("Blue Cerulean", QChart::ChartThemeBlueCerulean);
+ themeComboBox->addItem("Dark", QChart::ChartThemeDark);
+ themeComboBox->addItem("Brown Sand", QChart::ChartThemeBrownSand);
+ themeComboBox->addItem("Blue NCS", QChart::ChartThemeBlueNcs);
+ themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast);
+ themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy);
+ themeComboBox->addItem("Qt", QChart::ChartThemeQt);
+ return themeComboBox;
+}
+
+QComboBox *ThemeWidget::createAnimationBox() const
+{
+ // settings layout
+ QComboBox *animationComboBox = new QComboBox();
+ animationComboBox->addItem("No Animations", QChart::NoAnimation);
+ animationComboBox->addItem("GridAxis Animations", QChart::GridAxisAnimations);
+ animationComboBox->addItem("Series Animations", QChart::SeriesAnimations);
+ animationComboBox->addItem("All Animations", QChart::AllAnimations);
+ return animationComboBox;
+}
+
+QComboBox *ThemeWidget::createLegendBox() const
+{
+ QComboBox *legendComboBox = new QComboBox();
+ legendComboBox->addItem("No Legend ", 0);
+ legendComboBox->addItem("Legend Top", Qt::AlignTop);
+ legendComboBox->addItem("Legend Bottom", Qt::AlignBottom);
+ legendComboBox->addItem("Legend Left", Qt::AlignLeft);
+ legendComboBox->addItem("Legend Right", Qt::AlignRight);
+ return legendComboBox;
+}
+
+QChart *ThemeWidget::createAreaChart() const
+{
+ QChart *chart = new QChart();
+ chart->setTitle("Area chart");
+
+ // The lower series initialized to zero values
+ QLineSeries *lowerSeries = 0;
+ QString name("Series ");
+ int nameIndex = 0;
+ for (int i(0); i < m_dataTable.count(); i++) {
+ QLineSeries *upperSeries = new QLineSeries(chart);
+ for (int j(0); j < m_dataTable[i].count(); j++) {
+ Data data = m_dataTable[i].at(j);
+ if (lowerSeries) {
+ const QList<QPointF>& points = lowerSeries->points();
+ upperSeries->append(QPointF(j, points[i].y() + data.first.y()));
+ } else {
+ upperSeries->append(QPointF(j, data.first.y()));
+ }
+ }
+ QAreaSeries *area = new QAreaSeries(upperSeries, lowerSeries);
+ area->setName(name + QString::number(nameIndex));
+ nameIndex++;
+ chart->addSeries(area);
+ chart->createDefaultAxes();
+ lowerSeries = upperSeries;
+ }
+
+ return chart;
+}
+
+QChart *ThemeWidget::createBarChart(int valueCount) const
+{
+ Q_UNUSED(valueCount);
+ QChart *chart = new QChart();
+ chart->setTitle("Bar chart");
+
+ QStackedBarSeries *series = new QStackedBarSeries(chart);
+ for (int i(0); i < m_dataTable.count(); i++) {
+ QBarSet *set = new QBarSet("Bar set " + QString::number(i));
+ foreach (Data data, m_dataTable[i])
+ *set << data.first.y();
+ series->append(set);
+ }
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+
+ return chart;
+}
+
+QChart *ThemeWidget::createLineChart() const
+{
+ QChart *chart = new QChart();
+ chart->setTitle("Line chart");
+
+ QString name("Series ");
+ int nameIndex = 0;
+ foreach (DataList list, m_dataTable) {
+ QLineSeries *series = new QLineSeries(chart);
+ foreach (Data data, list)
+ series->append(data.first);
+ series->setName(name + QString::number(nameIndex));
+ nameIndex++;
+ chart->addSeries(series);
+ }
+ chart->createDefaultAxes();
+
+ return chart;
+}
+
+QChart *ThemeWidget::createPieChart() const
+{
+ QChart *chart = new QChart();
+ chart->setTitle("Pie chart");
+
+ qreal pieSize = 1.0 / m_dataTable.count();
+ for (int i = 0; i < m_dataTable.count(); i++) {
+ QPieSeries *series = new QPieSeries(chart);
+ foreach (Data data, m_dataTable[i]) {
+ QPieSlice *slice = series->append(data.second, data.first.y());
+ if (data == m_dataTable[i].first()) {
+ slice->setLabelVisible();
+ slice->setExploded();
+ }
+ }
+ qreal hPos = (pieSize / 2) + (i / (qreal) m_dataTable.count());
+ series->setPieSize(pieSize);
+ series->setHorizontalPosition(hPos);
+ series->setVerticalPosition(0.5);
+ chart->addSeries(series);
+ }
+
+ return chart;
+}
+
+QChart *ThemeWidget::createSplineChart() const
+{
+ // spine chart
+ QChart *chart = new QChart();
+ chart->setTitle("Spline chart");
+ QString name("Series ");
+ int nameIndex = 0;
+ foreach (DataList list, m_dataTable) {
+ QSplineSeries *series = new QSplineSeries(chart);
+ foreach (Data data, list)
+ series->append(data.first);
+ series->setName(name + QString::number(nameIndex));
+ nameIndex++;
+ chart->addSeries(series);
+ }
+ chart->createDefaultAxes();
+ return chart;
+}
+
+QChart *ThemeWidget::createScatterChart() const
+{
+ // scatter chart
+ QChart *chart = new QChart();
+ chart->setTitle("Scatter chart");
+ QString name("Series ");
+ int nameIndex = 0;
+ foreach (DataList list, m_dataTable) {
+ QScatterSeries *series = new QScatterSeries(chart);
+ foreach (Data data, list)
+ series->append(data.first);
+ series->setName(name + QString::number(nameIndex));
+ nameIndex++;
+ chart->addSeries(series);
+ }
+ chart->createDefaultAxes();
+ return chart;
+}
+
+void ThemeWidget::updateUI()
+{
+ QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
+
+ if (m_charts.at(0)->chart()->theme() != theme) {
+ foreach (QChartView *chartView, m_charts)
+ chartView->chart()->setTheme(theme);
+
+ QPalette pal = window()->palette();
+ if (theme == QChart::ChartThemeLight) {
+ pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
+ pal.setColor(QPalette::WindowText, QRgb(0x404044));
+ } else if (theme == QChart::ChartThemeDark) {
+ pal.setColor(QPalette::Window, QRgb(0x121218));
+ pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
+ } else if (theme == QChart::ChartThemeBlueCerulean) {
+ pal.setColor(QPalette::Window, QRgb(0x40434a));
+ pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
+ } else if (theme == QChart::ChartThemeBrownSand) {
+ pal.setColor(QPalette::Window, QRgb(0x9e8965));
+ pal.setColor(QPalette::WindowText, QRgb(0x404044));
+ } else if (theme == QChart::ChartThemeBlueNcs) {
+ pal.setColor(QPalette::Window, QRgb(0x018bba));
+ pal.setColor(QPalette::WindowText, QRgb(0x404044));
+ } else if (theme == QChart::ChartThemeHighContrast) {
+ pal.setColor(QPalette::Window, QRgb(0xffab03));
+ pal.setColor(QPalette::WindowText, QRgb(0x181818));
+ } else if (theme == QChart::ChartThemeBlueIcy) {
+ pal.setColor(QPalette::Window, QRgb(0xcee7f0));
+ pal.setColor(QPalette::WindowText, QRgb(0x404044));
+ } else {
+ pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
+ pal.setColor(QPalette::WindowText, QRgb(0x404044));
+ }
+ window()->setPalette(pal);
+ }
+
+ bool checked = m_antialiasCheckBox->isChecked();
+ foreach (QChartView *chart, m_charts)
+ chart->setRenderHint(QPainter::Antialiasing, checked);
+
+ QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt());
+ if (m_charts.at(0)->chart()->animationOptions() != options) {
+ foreach (QChartView *chartView, m_charts)
+ chartView->chart()->setAnimationOptions(options);
+ }
+
+ Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt());
+
+ if (!alignment) {
+ foreach (QChartView *chartView, m_charts)
+ chartView->chart()->legend()->hide();
+ } else {
+ foreach (QChartView *chartView, m_charts) {
+ chartView->chart()->legend()->setAlignment(alignment);
+ chartView->chart()->legend()->show();
+ }
+ }
+}
+
diff --git a/examples/charts/chartthemes/themewidget.h b/examples/charts/chartthemes/themewidget.h
new file mode 100644
index 00000000..d1a4d997
--- /dev/null
+++ b/examples/charts/chartthemes/themewidget.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 THEMEWIDGET_H
+#define THEMEWIDGET_H
+
+#include <QWidget>
+#include <QChartGlobal>
+
+class QComboBox;
+class QCheckBox;
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QChartView;
+class QChart;
+QT_CHARTS_END_NAMESPACE
+
+typedef QPair<QPointF, QString> Data;
+typedef QList<Data> DataList;
+typedef QList<DataList> DataTable;
+
+QT_CHARTS_USE_NAMESPACE
+
+class ThemeWidget: public QWidget
+{
+ Q_OBJECT
+public:
+ explicit ThemeWidget(QWidget *parent = 0);
+ ~ThemeWidget();
+
+private Q_SLOTS:
+ void updateUI();
+
+private:
+ DataTable generateRandomData(int listCount, int valueMax, int valueCount) const;
+ QComboBox *createThemeBox() const;
+ QComboBox *createAnimationBox() const;
+ QComboBox *createLegendBox() const;
+ void connectSignals();
+ QChart *createAreaChart() const;
+ QChart *createBarChart(int valueCount) const;
+ QChart *createPieChart() const;
+ QChart *createLineChart() const;
+ QChart *createSplineChart() const;
+ QChart *createScatterChart() const;
+
+private:
+ int m_listCount;
+ int m_valueMax;
+ int m_valueCount;
+ QList<QChartView *> m_charts;
+ DataTable m_dataTable;
+
+ QComboBox *m_themeComboBox;
+ QCheckBox *m_antialiasCheckBox;
+ QComboBox *m_animatedComboBox;
+ QComboBox *m_legendComboBox;
+};
+
+#endif /* THEMEWIDGET_H */
diff --git a/examples/charts/customchart/customchart.pro b/examples/charts/customchart/customchart.pro
new file mode 100644
index 00000000..5f3f7382
--- /dev/null
+++ b/examples/charts/customchart/customchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = customchart
+SOURCES += main.cpp
diff --git a/examples/charts/customchart/main.cpp b/examples/charts/customchart/main.cpp
new file mode 100644
index 00000000..8a35dfb1
--- /dev/null
+++ b/examples/charts/customchart/main.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+#include <QCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QLineSeries *series = new QLineSeries();
+ *series << QPointF(0, 6) << QPointF(9, 4) << QPointF(15, 20) << QPointF(25, 12) << QPointF(29, 26);
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->addSeries(series);
+//![1]
+
+//![2]
+ // Customize series
+ QPen pen(QRgb(0xfdb157));
+ pen.setWidth(5);
+ series->setPen(pen);
+
+ // Customize chart title
+ QFont font;
+ font.setPixelSize(18);
+ chart->setTitleFont(font);
+ chart->setTitleBrush(QBrush(Qt::white));
+ chart->setTitle("Customchart example");
+
+ // Customize chart background
+ QLinearGradient backgroundGradient;
+ backgroundGradient.setStart(QPointF(0, 0));
+ backgroundGradient.setFinalStop(QPointF(0, 1));
+ backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1));
+ backgroundGradient.setColorAt(1.0, QRgb(0x4c4547));
+ backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
+ chart->setBackgroundBrush(backgroundGradient);
+
+ // Customize plot area background
+ QLinearGradient plotAreaGradient;
+ plotAreaGradient.setStart(QPointF(0, 1));
+ plotAreaGradient.setFinalStop(QPointF(1, 0));
+ plotAreaGradient.setColorAt(0.0, QRgb(0x555555));
+ plotAreaGradient.setColorAt(1.0, QRgb(0x55aa55));
+ plotAreaGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
+ chart->setPlotAreaBackgroundBrush(plotAreaGradient);
+ chart->setPlotAreaBackgroundVisible(true);
+//![2]
+
+//![3]
+ QCategoryAxis *axisX = new QCategoryAxis();
+ QCategoryAxis *axisY = new QCategoryAxis();
+
+ // Customize axis label font
+ QFont labelsFont;
+ labelsFont.setPixelSize(12);
+ axisX->setLabelsFont(labelsFont);
+ axisY->setLabelsFont(labelsFont);
+
+ // Customize axis colors
+ QPen axisPen(QRgb(0xd18952));
+ axisPen.setWidth(2);
+ axisX->setLinePen(axisPen);
+ axisY->setLinePen(axisPen);
+
+ // Customize axis label colors
+ QBrush axisBrush(Qt::white);
+ axisX->setLabelsBrush(axisBrush);
+ axisY->setLabelsBrush(axisBrush);
+
+ // Customize grid lines and shades
+ axisX->setGridLineVisible(false);
+ axisY->setGridLineVisible(false);
+ axisY->setShadesPen(Qt::NoPen);
+ axisY->setShadesBrush(QBrush(QColor(0x99, 0xcc, 0xcc, 0x55)));
+ axisY->setShadesVisible(true);
+//![3]
+
+//![4]
+ axisX->append("low", 10);
+ axisX->append("optimal", 20);
+ axisX->append("high", 30);
+ axisX->setRange(0, 30);
+
+ axisY->append("slow", 10);
+ axisY->append("med", 20);
+ axisY->append("fast", 30);
+ axisY->setRange(0, 30);
+
+ chart->setAxisX(axisX, series);
+ chart->setAxisY(axisY, series);
+//![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();
+}
diff --git a/examples/charts/datetimeaxis/datetimeaxis.pro b/examples/charts/datetimeaxis/datetimeaxis.pro
new file mode 100644
index 00000000..0ec9d715
--- /dev/null
+++ b/examples/charts/datetimeaxis/datetimeaxis.pro
@@ -0,0 +1,8 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = datetimeaxis
+SOURCES += main.cpp
+
+RESOURCES += \
+ sundata.qrc
diff --git a/examples/charts/datetimeaxis/main.cpp b/examples/charts/datetimeaxis/main.cpp
new file mode 100644
index 00000000..988b74f2
--- /dev/null
+++ b/examples/charts/datetimeaxis/main.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+#include <QDateTime>
+#include <QDateTimeAxis>
+#include <QFile>
+#include <QTextStream>
+#include <QDebug>
+#include <QValueAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ //![1]
+ QLineSeries *series = new QLineSeries();
+ //![1]
+
+ //![2]
+ // data from http://www.swpc.noaa.gov/ftpdir/weekly/RecentIndices.txt
+ // http://www.swpc.noaa.gov/ftpdir/weekly/README
+ // http://www.weather.gov/disclaimer
+ QFile sunSpots(":sun");
+ if (!sunSpots.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ return 1;
+ }
+
+ QTextStream stream(&sunSpots);
+ while (!stream.atEnd()) {
+ QString line = stream.readLine();
+ if (line.startsWith("#") || line.startsWith(":"))
+ continue;
+ QStringList values = line.split(" ", QString::SkipEmptyParts);
+ QDateTime momentInTime;
+ momentInTime.setDate(QDate(values[0].toInt(), values[1].toInt() , 15));
+ series->append(momentInTime.toMSecsSinceEpoch(), values[2].toDouble());
+ }
+ sunSpots.close();
+ //![2]
+
+ //![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->legend()->hide();
+ chart->setTitle("Sunspots count (by Space Weather Prediction Center)");
+ //![3]
+
+ //![4]
+ QDateTimeAxis *axisX = new QDateTimeAxis;
+ axisX->setTickCount(10);
+ axisX->setFormat("MMM yyyy");
+ axisX->setTitleText("Date");
+ chart->addAxis(axisX, Qt::AlignBottom);
+ series->attachAxis(axisX);
+
+ QValueAxis *axisY = new QValueAxis;
+ axisY->setLabelFormat("%i");
+ axisY->setTitleText("Sunspots count");
+ chart->addAxis(axisY, Qt::AlignLeft);
+ series->attachAxis(axisY);
+ //![4]
+
+ //![5]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ //![5]
+
+ //![6]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(820, 600);
+ window.show();
+ //![6]
+
+ return a.exec();
+}
diff --git a/examples/charts/datetimeaxis/sun_spots.txt b/examples/charts/datetimeaxis/sun_spots.txt
new file mode 100644
index 00000000..91ef5982
--- /dev/null
+++ b/examples/charts/datetimeaxis/sun_spots.txt
@@ -0,0 +1,284 @@
+:Recent_Solar_Indices: RecentIndices.txt
+:Created: 2012 Aug 06 0759 UTC
+# Prepared by the U.S. Dept. of Commerce, NOAA, Space Weather Prediction Center (SWPC).
+# Please send comments and suggestions to swpc.webmaster@noaa.gov
+#
+# Source SWO: SWPC Space Weather Operations (SWO).
+# Source RI: S.I.D.C. Brussels International Sunspot Number.
+# Source 10.7cm radio flux values (sfu): Penticton, B.C., Canada.
+#
+# Source Ap: GeoForschungsZentrum, Postdam, Germany
+# Prior to January 1997, Institut fur Geophysik, Gottingen, Germany
+# Source Ap for final month is NOAA/SWPC estimated Ap.
+#
+# Data not yet available or not calculable: -1.0
+#
+# Values for most recent 6 months are considered preliminary.
+# Final values from National Geophysical Data Center www.ngdc.noaa.gov
+#
+# Recent Solar Indices
+# of Observed Monthly Mean Values
+#
+# -----------Sunspot Numbers--------- ----Radio Flux--- ---Geomagnetic---
+# ---Observed---- Ratio --Smoothed- Observed Smoothed Observed Smoothed
+# YR MO SWO RI RI/SW SWO RI 10.7cm 10.7cm Ap Ap
+#-------------------------------------------------------------------------------
+1991 01 213.5 136.9 0.64 220.5 147.6 229.4 205.5 8 17.4
+1991 02 270.2 167.5 0.62 221.5 147.6 243.0 206.3 10 18.4
+1991 03 227.9 141.9 0.62 220.7 146.6 230.0 205.9 27 19.1
+1991 04 215.9 140.0 0.65 220.7 146.5 198.8 206.8 17 20.0
+1991 05 182.5 121.3 0.66 219.6 145.5 190.3 207.1 18 21.7
+1991 06 231.8 169.7 0.73 218.9 145.2 206.8 207.4 44 23.0
+1991 07 245.7 173.7 0.71 219.5 146.3 212.0 207.7 27 23.6
+1991 08 251.5 176.3 0.70 218.3 146.6 210.3 206.8 30 24.7
+1991 09 185.8 125.3 0.67 214.2 144.9 180.6 203.9 20 25.0
+1991 10 220.1 144.1 0.65 208.4 141.7 201.3 199.7 31 24.3
+1991 11 169.0 108.2 0.64 202.2 138.1 172.0 195.4 33 24.1
+1991 12 217.7 144.4 0.66 193.7 131.7 223.9 188.9 15 23.0
+1992 01 217.9 150.0 0.69 183.3 123.7 217.6 181.8 14 21.1
+1992 02 238.2 161.1 0.68 171.8 115.4 232.1 174.8 31 19.8
+1992 03 160.5 106.7 0.66 161.6 108.2 171.3 168.5 14 19.4
+1992 04 144.0 99.8 0.69 154.3 103.3 158.5 162.9 11 18.9
+1992 05 106.3 73.8 0.69 148.9 100.3 125.4 158.9 21 17.5
+1992 06 104.7 65.2 0.62 143.3 97.1 116.7 154.3 15 16.6
+1992 07 121.4 85.7 0.71 134.3 90.7 132.2 146.7 10 16.6
+1992 08 99.5 64.5 0.65 124.4 84.0 122.1 138.9 15 16.1
+1992 09 93.8 63.9 0.68 117.5 79.5 116.8 133.8 25 15.9
+1992 10 136.2 88.7 0.65 113.4 76.4 131.7 130.5 15 16.7
+1992 11 124.3 91.8 0.74 110.4 74.4 145.2 128.2 14 16.6
+1992 12 127.4 82.6 0.65 107.7 73.2 139.1 127.4 13 16.1
+1993 01 92.1 59.3 0.64 104.5 71.4 121.0 125.7 17 16.0
+1993 02 126.1 91.0 0.72 101.2 69.3 142.6 123.1 16 15.9
+1993 03 107.4 69.8 0.65 97.0 66.6 136.4 120.7 24 15.3
+1993 04 98.6 62.2 0.63 91.9 63.6 115.9 118.1 19 14.9
+1993 05 79.1 61.3 0.77 86.2 59.9 112.4 114.8 12 14.9
+1993 06 68.5 49.8 0.73 81.0 56.1 109.3 111.3 12 15.0
+1993 07 81.6 57.9 0.71 78.7 54.7 99.0 109.6 10 14.9
+1993 08 59.4 42.2 0.71 75.7 52.3 93.7 107.6 12 15.4
+1993 09 33.5 22.4 0.67 70.7 48.4 87.0 103.9 15 16.0
+1993 10 73.5 56.4 0.77 65.5 44.9 100.3 100.4 14 16.4
+1993 11 51.0 35.6 0.70 60.8 41.2 95.9 97.5 15 17.4
+1993 12 75.9 48.9 0.64 57.9 38.4 104.8 94.8 14 18.1
+1994 01 86.4 57.8 0.67 55.6 36.6 115.0 92.7 15 18.2
+1994 02 60.5 35.5 0.59 53.5 34.8 99.6 91.2 30 18.1
+1994 03 52.4 31.7 0.60 52.9 34.1 90.4 90.2 24 17.8
+1994 04 29.3 16.1 0.55 53.0 33.7 79.1 89.3 29 18.0
+1994 05 35.4 17.8 0.50 51.9 32.5 79.9 88.1 26 18.3
+1994 06 42.6 28.0 0.66 49.6 30.8 77.3 86.4 14 18.2
+1994 07 52.7 35.1 0.67 46.1 28.5 80.5 83.9 11 18.1
+1994 08 38.4 22.5 0.59 43.8 26.8 76.1 82.0 8 17.5
+1994 09 40.5 25.7 0.63 43.4 26.6 79.0 81.2 12 16.5
+1994 10 67.1 44.0 0.66 43.2 26.5 87.7 80.9 22 15.5
+1994 11 33.0 18.0 0.55 42.5 26.2 80.9 80.6 14 14.7
+1994 12 38.7 26.2 0.68 41.4 25.6 77.4 80.4 13 14.2
+1995 01 39.8 24.2 0.61 39.6 24.2 82.7 80.1 14 14.0
+1995 02 51.3 29.9 0.58 37.8 23.0 85.6 79.7 15 13.9
+1995 03 51.9 31.1 0.60 36.3 22.1 85.1 79.3 15 14.0
+1995 04 23.6 14.0 0.59 33.8 20.6 77.7 78.6 16 13.8
+1995 05 24.6 14.5 0.59 31.6 19.2 75.5 77.9 18 13.3
+1995 06 27.8 15.6 0.56 29.9 18.2 75.7 77.4 11 12.9
+1995 07 23.8 14.5 0.61 28.1 17.0 73.9 76.9 8 12.5
+1995 08 25.1 14.3 0.57 25.4 15.4 73.8 76.0 9 12.1
+1995 09 16.5 11.8 0.72 22.0 13.4 72.0 74.8 13 11.8
+1995 10 31.6 21.1 0.67 19.7 12.1 77.9 73.8 16 11.4
+1995 11 15.7 9.0 0.57 18.5 11.3 74.2 73.2 9 10.7
+1995 12 16.2 10.0 0.62 17.6 10.8 72.6 72.8 9 10.0
+1996 01 17.6 11.5 0.65 16.8 10.4 74.5 72.4 9 9.7
+1996 02 9.1 4.4 0.48 16.2 10.1 71.5 72.2 10 9.7
+1996 03 12.1 9.2 0.76 15.4 9.7 70.7 72.1 11 9.8
+1996 04 8.5 4.8 0.56 13.6 8.4 69.3 71.6 11 9.7
+1996 05 11.8 5.5 0.47 12.9 8.0 70.1 71.4 7 9.5
+1996 06 18.8 11.8 0.63 13.5 8.5 69.6 71.8 5 9.4
+1996 07 13.2 8.2 0.62 13.4 8.4 71.2 72.0 7 9.3
+1996 08 20.5 14.4 0.70 13.1 8.3 72.4 72.1 9 9.4
+1996 09 2.9 1.6 0.55 13.3 8.4 69.4 72.3 15 9.3
+1996 10 2.3 0.9 0.39 14.0 8.8 69.2 72.6 13 9.1
+1996 11 26.7 17.9 0.67 15.4 9.8 78.7 73.0 8 9.1
+1996 12 21.1 13.3 0.63 16.2 10.4 77.8 73.3 7 9.3
+1997 01 9.0 5.7 0.63 16.5 10.5 74.0 73.4 9 9.3
+1997 02 11.3 7.6 0.67 17.4 11.0 73.8 73.7 11 9.2
+1997 03 14.4 8.7 0.60 20.4 13.5 73.5 75.1 8 8.9
+1997 04 24.5 15.5 0.63 24.0 16.5 74.5 76.8 10 8.5
+1997 05 28.6 18.5 0.65 26.4 18.4 74.6 78.4 8 8.5
+1997 06 22.1 12.7 0.57 29.0 20.4 71.7 80.1 7 8.5
+1997 07 17.0 10.4 0.61 32.4 22.7 71.1 81.8 6 8.4
+1997 08 36.7 24.4 0.66 35.9 25.1 79.0 83.4 7 8.2
+1997 09 58.2 51.3 0.88 40.5 28.4 96.2 85.7 10 8.3
+1997 10 33.6 23.8 0.71 45.4 31.9 84.9 88.6 10 8.5
+1997 11 53.5 39.0 0.73 49.3 35.0 99.5 91.3 11 8.9
+1997 12 57.9 41.2 0.71 54.2 39.0 98.8 94.2 4 9.5
+1998 01 51.8 31.9 0.62 60.6 43.8 93.4 97.5 8 9.8
+1998 02 54.4 40.3 0.74 67.4 49.0 93.4 101.7 8 10.5
+1998 03 81.8 54.8 0.67 73.3 53.5 109.1 105.8 13 11.0
+1998 04 73.6 53.4 0.73 77.7 56.6 108.3 108.9 10 11.3
+1998 05 74.3 56.3 0.76 81.4 59.4 106.7 112.0 18 11.6
+1998 06 93.6 70.7 0.76 85.9 62.5 108.4 115.8 10 12.0
+1998 07 98.3 66.6 0.68 90.3 65.5 114.0 120.0 11 12.3
+1998 08 118.6 92.2 0.78 93.7 67.8 136.0 124.1 18 12.5
+1998 09 119.0 92.9 0.78 96.1 69.5 138.3 126.8 13 12.7
+1998 10 77.0 55.5 0.72 97.7 70.5 117.3 127.9 13 12.8
+1998 11 99.5 74.0 0.74 101.3 73.0 140.2 130.0 16 12.5
+1998 12 120.8 81.9 0.68 108.8 77.9 150.1 134.3 8 12.0
+1999 01 94.3 62.0 0.66 116.5 82.6 142.6 139.0 10 11.8
+1999 02 93.4 66.3 0.71 120.2 84.6 142.0 142.6 12 11.6
+1999 03 100.5 68.8 0.68 120.5 83.8 126.3 144.0 14 11.8
+1999 04 92.9 63.7 0.69 123.8 85.5 117.2 145.8 12 12.3
+1999 05 140.5 106.4 0.76 131.7 90.5 148.6 149.9 8 12.4
+1999 06 208.3 137.7 0.66 136.0 93.1 169.8 152.9 7 12.4
+1999 07 169.2 113.5 0.67 138.0 94.3 165.6 154.4 10 12.6
+1999 08 136.1 93.7 0.69 142.8 97.5 170.8 156.3 15 12.9
+1999 09 107.4 71.5 0.67 150.0 102.3 135.7 161.0 19 12.9
+1999 10 167.7 116.7 0.70 158.5 107.8 164.8 167.2 19 12.8
+1999 11 199.3 133.2 0.67 164.7 111.0 191.5 171.5 14 13.2
+1999 12 123.5 84.6 0.69 165.9 111.1 169.8 173.4 10 13.8
+2000 01 140.8 90.1 0.64 168.0 112.9 158.1 175.5 13 14.6
+2000 02 161.9 112.9 0.70 172.1 116.8 173.2 176.8 16 15.1
+2000 03 203.6 138.5 0.68 175.4 119.9 208.2 178.4 9 15.1
+2000 04 193.4 125.5 0.65 176.3 120.8 184.2 180.5 15 15.0
+2000 05 188.8 121.6 0.64 173.1 119.0 184.5 180.0 15 15.1
+2000 06 190.3 124.9 0.66 172.0 118.7 179.8 179.7 15 15.1
+2000 07 236.7 170.1 0.72 173.0 119.8 204.7 180.2 21 14.8
+2000 08 166.6 130.5 0.78 171.8 118.6 163.1 179.4 16 14.2
+2000 09 157.9 109.7 0.69 169.0 116.3 182.1 177.1 18 14.3
+2000 10 138.9 99.4 0.72 166.2 114.5 167.7 175.5 18 15.0
+2000 11 149.9 106.8 0.71 162.7 112.7 178.8 173.8 17 15.1
+2000 12 146.4 104.4 0.71 160.8 112.0 173.6 172.0 7 14.7
+2001 01 142.7 95.6 0.67 156.3 108.7 166.6 168.7 8 14.0
+2001 02 131.0 80.6 0.62 151.4 104.0 146.7 165.6 7 13.3
+2001 03 166.7 113.5 0.68 154.0 104.8 177.7 167.8 20 12.9
+2001 04 163.6 107.7 0.66 159.4 107.5 178.1 171.6 22 12.8
+2001 05 135.1 96.6 0.72 163.1 108.6 147.9 174.7 10 12.8
+2001 06 196.7 134.0 0.68 167.2 109.8 173.7 178.7 10 12.8
+2001 07 124.6 81.8 0.66 172.1 111.7 131.3 183.8 9 12.9
+2001 08 159.4 106.4 0.67 176.7 113.6 163.1 188.8 11 13.0
+2001 09 229.1 150.7 0.66 178.8 114.1 233.8 191.3 13 12.8
+2001 10 197.4 125.5 0.64 179.5 114.0 208.1 191.9 20 12.1
+2001 11 178.6 106.5 0.60 183.7 115.5 212.7 193.7 16 12.0
+2001 12 217.5 132.2 0.61 184.5 114.6 235.6 193.9 9 12.0
+2002 01 189.0 114.1 0.60 184.8 113.5 227.3 194.6 8 11.9
+2002 02 194.5 107.4 0.55 188.6 114.6 205.0 197.2 10 12.1
+2002 03 153.1 98.4 0.64 188.9 113.3 180.3 195.7 10 12.3
+2002 04 194.9 120.7 0.62 186.2 110.5 189.8 191.5 17 12.5
+2002 05 204.1 120.8 0.59 183.6 108.8 178.4 188.0 12 12.7
+2002 06 146.0 88.3 0.60 179.9 106.2 148.7 182.9 7 12.9
+2002 07 183.5 99.6 0.54 175.4 102.7 173.5 176.2 11 13.3
+2002 08 191.0 116.4 0.61 169.2 98.7 183.9 169.3 14 13.8
+2002 09 206.4 109.6 0.53 163.4 94.6 175.8 164.0 13 14.5
+2002 10 153.9 97.5 0.63 158.8 90.5 167.0 159.3 25 15.1
+2002 11 159.8 95.5 0.60 150.9 85.2 168.7 154.1 17 15.8
+2002 12 147.9 80.8 0.55 145.0 82.0 157.2 150.7 13 17.1
+2003 01 149.3 79.7 0.53 141.7 80.8 144.0 148.0 13 18.2
+2003 02 87.0 46.0 0.53 136.4 78.3 124.5 143.5 17 18.9
+2003 03 119.7 61.1 0.51 128.1 74.0 132.2 138.3 21 19.5
+2003 04 119.7 60.0 0.50 121.5 70.1 126.3 135.0 20 20.1
+2003 05 89.6 54.6 0.61 118.3 67.6 116.2 133.1 26 21.0
+2003 06 118.4 77.4 0.65 113.6 65.0 129.3 130.2 24 21.5
+2003 07 132.8 83.3 0.63 106.9 61.8 127.7 127.2 19 22.0
+2003 08 114.3 72.7 0.64 102.8 60.0 122.1 125.2 23 22.3
+2003 09 82.6 48.7 0.59 100.7 59.5 112.2 123.7 18 21.8
+2003 10 118.9 65.5 0.55 96.6 58.2 151.3 121.8 35 21.1
+2003 11 118.9 67.3 0.57 93.6 56.7 140.8 120.1 28 20.0
+2003 12 75.4 46.5 0.62 91.4 54.8 115.0 118.0 16 18.6
+2004 01 62.3 37.3 0.60 87.9 52.0 114.1 116.3 22 18.1
+2004 02 75.6 45.8 0.61 84.2 49.3 107.0 115.5 13 17.7
+2004 03 81.0 49.1 0.61 80.9 47.1 112.0 114.6 14 16.7
+2004 04 59.3 39.3 0.66 77.9 45.5 101.2 112.4 11 15.2
+2004 05 77.3 41.5 0.54 74.1 43.8 99.8 109.3 8 14.0
+2004 06 78.9 43.2 0.55 70.4 41.6 97.4 107.4 8 13.6
+2004 07 87.8 51.1 0.58 68.3 40.2 118.5 106.1 23 13.5
+2004 08 69.5 40.9 0.59 66.6 39.2 111.0 105.2 9 13.5
+2004 09 50.0 27.7 0.55 63.7 37.5 103.0 103.8 9 13.3
+2004 10 77.9 48.0 0.62 61.3 35.9 105.9 102.3 8 13.3
+2004 11 70.5 43.5 0.62 60.0 35.3 113.7 101.6 25 13.7
+2004 12 34.7 17.9 0.52 58.8 35.2 95.0 101.5 11 14.3
+2005 01 52.0 31.3 0.60 57.3 34.6 102.2 100.4 24 14.1
+2005 02 45.4 29.2 0.64 56.4 33.9 97.2 98.6 11 14.0
+2005 03 41.0 24.5 0.60 55.8 33.5 89.9 97.3 12 14.6
+2005 04 41.5 24.2 0.58 52.6 31.6 86.0 95.5 11 15.1
+2005 05 65.4 42.7 0.65 48.3 28.9 99.5 93.2 19 14.4
+2005 06 59.8 39.3 0.66 47.9 28.8 93.7 91.9 12 13.6
+2005 07 71.0 40.1 0.56 48.1 29.1 96.5 90.9 14 12.8
+2005 08 65.6 36.4 0.55 45.4 27.4 90.5 89.2 14 11.8
+2005 09 39.2 21.9 0.56 42.9 25.8 91.1 87.8 20 11.4
+2005 10 13.0 8.7 0.67 42.6 25.5 76.6 87.3 8 11.3
+2005 11 32.2 18.0 0.56 42.1 24.9 86.2 86.7 8 10.8
+2005 12 62.6 41.1 0.66 40.1 23.0 90.7 85.2 9 10.0
+2006 01 28.0 15.3 0.55 37.2 20.8 83.4 83.6 6 9.5
+2006 02 5.3 4.9 0.92 33.4 18.6 76.5 82.3 6 9.0
+2006 03 21.3 10.6 0.50 31.0 17.4 75.5 81.2 8 8.3
+2006 04 55.2 30.2 0.55 30.6 17.1 89.0 80.6 11 7.8
+2006 05 39.6 22.3 0.56 30.7 17.3 80.9 80.5 7 7.9
+2006 06 37.7 13.9 0.37 28.9 16.3 76.5 80.2 7 8.2
+2006 07 22.6 12.2 0.54 27.2 15.2 75.8 80.0 6 8.6
+2006 08 22.8 12.9 0.57 27.6 15.6 79.4 80.1 9 8.8
+2006 09 25.2 14.4 0.57 27.7 15.5 77.8 80.0 8 8.8
+2006 10 15.7 10.5 0.67 25.2 14.2 74.3 79.1 9 8.8
+2006 11 31.5 21.4 0.68 22.3 12.6 86.3 78.2 9 8.7
+2006 12 22.2 13.6 0.61 20.7 12.1 84.5 77.8 15 8.7
+2007 01 26.6 16.8 0.63 19.7 11.9 83.5 77.5 10 8.7
+2007 02 17.2 10.7 0.62 18.9 11.5 77.7 76.9 7 8.6
+2007 03 9.7 4.5 0.46 17.5 10.7 72.2 76.0 8 8.5
+2007 04 6.9 3.4 0.49 16.0 9.8 72.4 75.3 9 8.5
+2007 05 19.4 11.7 0.60 14.2 8.6 74.4 74.3 8 8.3
+2007 06 20.0 12.1 0.61 12.8 7.6 73.7 73.3 6 7.9
+2007 07 15.6 9.7 0.62 11.6 6.9 71.6 72.7 7 7.4
+2007 08 9.9 6.0 0.61 10.2 6.0 69.1 72.1 6 7.5
+2007 09 4.8 2.4 0.50 9.9 5.9 67.0 71.8 9 7.8
+2007 10 1.3 0.9 0.69 10.0 6.0 67.5 71.8 7 7.9
+2007 11 2.5 1.7 0.68 9.4 5.7 69.6 71.4 7 7.8
+2007 12 16.2 10.1 0.62 8.1 4.9 78.5 70.8 6 7.8
+2008 01 5.1 3.3 0.65 6.9 4.2 74.3 70.3 8 7.8
+2008 02 3.8 2.1 0.55 5.9 3.6 71.1 69.9 11 7.6
+2008 03 15.9 9.3 0.58 5.3 3.3 72.9 69.8 11 7.5
+2008 04 4.9 2.9 0.59 5.3 3.4 70.2 69.8 9 7.3
+2008 05 5.7 3.2 0.56 5.7 3.5 68.4 69.8 6 7.2
+2008 06 4.2 3.4 0.81 5.2 3.3 65.9 69.4 7 7.0
+2008 07 1.0 0.8 0.80 4.5 2.8 65.7 68.8 5 6.8
+2008 08 0.0 0.5 -1.00 4.4 2.7 66.3 68.6 5 6.3
+2008 09 1.5 1.1 0.73 3.7 2.3 67.1 68.4 6 5.8
+2008 10 5.2 2.9 0.56 2.9 1.8 68.3 68.2 7 5.4
+2008 11 6.8 4.1 0.60 2.7 1.7 68.6 68.3 4 5.1
+2008 12 1.3 0.8 0.62 2.7 1.7 69.2 68.5 4 4.9
+2009 01 2.8 1.3 0.46 3.0 1.8 69.8 68.7 4 4.7
+2009 02 2.5 1.4 0.56 3.1 1.9 70.0 68.8 5 4.7
+2009 03 0.7 0.7 1.00 3.4 2.0 69.2 69.0 5 4.6
+2009 04 1.2 0.8 1.00 3.7 2.2 69.7 69.3 4 4.3
+2009 05 3.9 2.9 0.74 3.8 2.3 70.5 69.7 4 4.1
+2009 06 6.6 2.9 0.39 4.4 2.7 68.6 70.2 4 4.0
+2009 07 5.0 3.2 0.70 5.8 3.6 68.2 71.0 4 3.9
+2009 08 0.3 0.0 0.00 7.7 4.8 67.4 72.1 5 3.8
+2009 09 6.6 4.3 0.64 9.9 6.2 70.5 73.3 4 3.8
+2009 10 7.0 4.8 0.66 11.3 7.1 72.3 74.1 3 4.1
+2009 11 7.7 4.1 0.55 12.4 7.6 73.6 74.5 3 4.5
+2009 12 15.7 10.8 0.68 13.6 8.3 76.8 74.9 2 4.8
+2010 01 21.3 13.2 0.62 14.8 9.3 81.1 75.5 3 5.0
+2010 02 31.0 18.8 0.60 16.7 10.6 84.7 76.5 5 5.1
+2010 03 24.7 15.4 0.62 19.1 12.3 83.3 77.5 5 5.3
+2010 04 11.2 8.0 0.71 21.4 14.0 75.9 78.3 10 5.5
+2010 05 19.9 8.7 0.44 23.8 15.5 73.8 79.0 8 5.7
+2010 06 17.9 13.6 0.75 25.2 16.4 72.6 79.7 7 5.8
+2010 07 23.1 16.1 0.70 25.9 16.7 79.9 80.1 5 6.0
+2010 08 28.2 19.6 0.70 27.3 17.4 79.7 80.7 8 6.2
+2010 09 35.6 25.2 0.71 30.6 19.6 81.1 82.4 5 6.3
+2010 10 35.0 23.5 0.67 35.9 23.2 81.6 85.3 6 6.4
+2010 11 36.1 21.5 0.60 40.5 26.5 82.5 87.7 5 6.4
+2010 12 22.0 14.4 0.66 43.8 28.8 84.3 89.6 4 6.5
+2011 01 32.1 18.8 0.59 47.2 30.9 83.7 91.2 6 6.7
+2011 02 53.2 29.6 0.55 50.6 33.4 94.5 92.7 6 6.8
+2011 03 81.0 55.8 0.69 55.2 36.9 115.3 95.8 7 7.2
+2011 04 81.7 54.4 0.67 61.5 41.8 112.6 100.4 9 7.5
+2011 05 61.4 41.5 0.68 69.0 47.6 95.9 105.6 9 7.5
+2011 06 55.5 37.0 0.67 76.5 53.2 95.8 110.9 8 7.4
+2011 07 67.0 43.8 0.66 82.5 57.2 94.2 115.4 9 7.3
+2011 08 66.1 50.6 0.77 84.9 59.0 101.7 117.9 8 7.4
+2011 09 106.4 78.0 0.73 84.6 59.5 134.5 118.4 13 7.7
+2011 10 116.8 88.0 0.75 84.6 59.9 137.2 118.4 7 8.0
+2011 11 133.1 96.7 0.73 86.3 61.1 153.1 119.5 3 8.0
+2011 12 106.3 73.0 0.69 89.2 63.4 141.2 121.6 3 8.0
+2012 01 91.3 58.3 0.64 92.0 65.5 133.1 124.4 6 8.3
+2012 02 50.1 32.9 0.66 -1.0 -1.0 106.7 -1.0 7 -1.0
+2012 03 77.9 64.3 0.82 -1.0 -1.0 115.1 -1.0 14 -1.0
+2012 04 84.4 55.2 0.65 -1.0 -1.0 113.1 -1.0 9 -1.0
+2012 05 99.5 69.0 0.69 -1.0 -1.0 121.5 -1.0 8 -1.0
+2012 06 88.6 64.5 0.73 -1.0 -1.0 120.5 -1.0 10 -1.0
+2012 07 99.6 66.5 0.67 -1.0 -1.0 135.6 -1.0 13 -1.0
diff --git a/examples/charts/datetimeaxis/sundata.qrc b/examples/charts/datetimeaxis/sundata.qrc
new file mode 100644
index 00000000..318be590
--- /dev/null
+++ b/examples/charts/datetimeaxis/sundata.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="sun">sun_spots.txt</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/donutbreakdown/donutbreakdown.pro b/examples/charts/donutbreakdown/donutbreakdown.pro
new file mode 100644
index 00000000..fecef7b8
--- /dev/null
+++ b/examples/charts/donutbreakdown/donutbreakdown.pro
@@ -0,0 +1,12 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = donutbreakdown
+SOURCES += main.cpp\
+ donutbreakdownchart.cpp \
+ mainslice.cpp
+
+HEADERS += \
+ donutbreakdownchart.h \
+ mainslice.h
diff --git a/examples/charts/donutbreakdown/donutbreakdownchart.cpp b/examples/charts/donutbreakdown/donutbreakdownchart.cpp
new file mode 100644
index 00000000..5272f105
--- /dev/null
+++ b/examples/charts/donutbreakdown/donutbreakdownchart.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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 "donutbreakdownchart.h"
+#include "mainslice.h"
+#include <QPieSlice>
+#include <QPieLegendMarker>
+
+QT_CHARTS_USE_NAMESPACE
+
+//![1]
+DonutBreakdownChart::DonutBreakdownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QChart(QChart::ChartTypeCartesian, parent, wFlags)
+{
+ // create the series for main center pie
+ m_mainSeries = new QPieSeries();
+ m_mainSeries->setPieSize(0.7);
+ QChart::addSeries(m_mainSeries);
+}
+//![1]
+
+//![2]
+void DonutBreakdownChart::addBreakdownSeries(QPieSeries *breakdownSeries, QColor color)
+{
+ QFont font("Arial", 8);
+
+ // add breakdown series as a slice to center pie
+ MainSlice *mainSlice = new MainSlice(breakdownSeries);
+ mainSlice->setName(breakdownSeries->name());
+ mainSlice->setValue(breakdownSeries->sum());
+ m_mainSeries->append(mainSlice);
+
+ // customize the slice
+ mainSlice->setBrush(color);
+ mainSlice->setLabelVisible();
+ mainSlice->setLabelColor(Qt::white);
+ mainSlice->setLabelPosition(QPieSlice::LabelInsideHorizontal);
+ mainSlice->setLabelFont(font);
+
+ // position and customize the breakdown series
+ breakdownSeries->setPieSize(0.8);
+ breakdownSeries->setHoleSize(0.7);
+ breakdownSeries->setLabelsVisible();
+ foreach (QPieSlice *slice, breakdownSeries->slices()) {
+ color = color.lighter(115);
+ slice->setBrush(color);
+ slice->setLabelFont(font);
+ }
+
+ // add the series to the chart
+ QChart::addSeries(breakdownSeries);
+
+ // recalculate breakdown donut segments
+ recalculateAngles();
+
+ // update customize legend markers
+ updateLegendMarkers();
+}
+//![2]
+
+//![3]
+void DonutBreakdownChart::recalculateAngles()
+{
+ qreal angle = 0;
+ foreach (QPieSlice *slice, m_mainSeries->slices()) {
+ QPieSeries *breakdownSeries = qobject_cast<MainSlice *>(slice)->breakdownSeries();
+ breakdownSeries->setPieStartAngle(angle);
+ angle += slice->percentage() * 360.0; // full pie is 360.0
+ breakdownSeries->setPieEndAngle(angle);
+ }
+}
+//![3]
+
+//![4]
+void DonutBreakdownChart::updateLegendMarkers()
+{
+ // go through all markers
+ foreach (QAbstractSeries *series, QChart::series()) {
+ foreach (QLegendMarker *marker, legend()->markers(series)) {
+ QPieLegendMarker *pieMarker = qobject_cast<QPieLegendMarker *>(marker);
+ if (series == m_mainSeries) {
+ // hide markers from main series
+ pieMarker->setVisible(false);
+ } else {
+ // modify markers from breakdown series
+ pieMarker->setLabel(QString("%1 %2%")
+ .arg(pieMarker->slice()->label())
+ .arg(pieMarker->slice()->percentage() * 100, 0, 'f', 2));
+ pieMarker->setFont(QFont("Arial", 8));
+ }
+ }
+ }
+}
+//![4]
diff --git a/examples/charts/donutbreakdown/donutbreakdownchart.h b/examples/charts/donutbreakdown/donutbreakdownchart.h
new file mode 100644
index 00000000..71b3ecf4
--- /dev/null
+++ b/examples/charts/donutbreakdown/donutbreakdownchart.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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 DONUTBREAKDOWNCHART_H
+#define DONUTBREAKDOWNCHART_H
+
+#include <QChart>
+#include <QPieSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class DonutBreakdownChart : public QChart
+{
+public:
+ DonutBreakdownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ void addBreakdownSeries(QPieSeries *series, QColor color);
+
+private:
+ void recalculateAngles();
+ void updateLegendMarkers();
+
+private:
+ QPieSeries *m_mainSeries;
+};
+
+#endif // DONUTBREAKDOWNCHART_H
diff --git a/examples/charts/donutbreakdown/main.cpp b/examples/charts/donutbreakdown/main.cpp
new file mode 100644
index 00000000..fb3925b6
--- /dev/null
+++ b/examples/charts/donutbreakdown/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 <QStatusBar>
+#include <QChartView>
+#include "donutbreakdownchart.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ //![1]
+ // Graph is based on data of 'Total consumption of energy increased by 10 per cent in 2010'
+ // Statistics Finland, 13 December 2011
+ // http://www.stat.fi/til/ekul/2010/ekul_2010_2011-12-13_tie_001_en.html
+
+ QPieSeries *series1 = new QPieSeries();
+ series1->setName("Fossil fuels");
+ series1->append("Oil", 353295);
+ series1->append("Coal", 188500);
+ series1->append("Natural gas", 148680);
+ series1->append("Peat", 94545);
+
+ QPieSeries *series2 = new QPieSeries();
+ series2->setName("Renewables");
+ series2->append("Wood fuels", 319663);
+ series2->append("Hydro power", 45875);
+ series2->append("Wind power", 1060);
+
+ QPieSeries *series3 = new QPieSeries();
+ series3->setName("Others");
+ series3->append("Nuclear energy", 238789);
+ series3->append("Import energy", 37802);
+ series3->append("Other", 32441);
+ //![1]
+
+ //![2]
+ DonutBreakdownChart *donutBreakdown = new DonutBreakdownChart();
+ donutBreakdown->setAnimationOptions(QChart::AllAnimations);
+ donutBreakdown->setTitle("Total consumption of energy in Finland 2010");
+ donutBreakdown->legend()->setAlignment(Qt::AlignRight);
+ donutBreakdown->addBreakdownSeries(series1, Qt::red);
+ donutBreakdown->addBreakdownSeries(series2, Qt::darkGreen);
+ donutBreakdown->addBreakdownSeries(series3, Qt::darkBlue);
+ //![2]
+
+ //![3]
+ QMainWindow window;
+ QChartView *chartView = new QChartView(donutBreakdown);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ window.setCentralWidget(chartView);
+ window.resize(800, 500);
+ window.show();
+ //![3]
+
+ return a.exec();
+}
diff --git a/examples/charts/donutbreakdown/mainslice.cpp b/examples/charts/donutbreakdown/mainslice.cpp
new file mode 100644
index 00000000..0ac83b3c
--- /dev/null
+++ b/examples/charts/donutbreakdown/mainslice.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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 "mainslice.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+//![1]
+MainSlice::MainSlice(QPieSeries *breakdownSeries, QObject *parent)
+ : QPieSlice(parent),
+ m_breakdownSeries(breakdownSeries)
+{
+ connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel()));
+}
+//![1]
+
+QPieSeries *MainSlice::breakdownSeries() const
+{
+ return m_breakdownSeries;
+}
+
+void MainSlice::setName(QString name)
+{
+ m_name = name;
+}
+
+QString MainSlice::name() const
+{
+ return m_name;
+}
+
+//![2]
+void MainSlice::updateLabel()
+{
+ this->setLabel(QString("%1 %2%").arg(m_name).arg(percentage() * 100, 0, 'f', 2));
+}
+//![2]
+
+#include "moc_mainslice.cpp"
+
diff --git a/examples/charts/donutbreakdown/mainslice.h b/examples/charts/donutbreakdown/mainslice.h
new file mode 100644
index 00000000..6c6d63c2
--- /dev/null
+++ b/examples/charts/donutbreakdown/mainslice.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 MAINSLICE_H
+#define MAINSLICE_H
+
+#include <QPieSlice>
+#include <QPieSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class MainSlice : public QPieSlice
+{
+ Q_OBJECT
+public:
+ MainSlice(QPieSeries *breakdownSeries, QObject *parent = 0);
+
+ QPieSeries *breakdownSeries() const;
+
+ void setName(QString name);
+ QString name() const;
+
+public Q_SLOTS:
+ void updateLabel();
+
+private:
+ QPieSeries *m_breakdownSeries;
+ QString m_name;
+};
+
+#endif // MAINSLICE_H
diff --git a/examples/charts/donutchart/donutchart.pro b/examples/charts/donutchart/donutchart.pro
new file mode 100644
index 00000000..72d4ea4d
--- /dev/null
+++ b/examples/charts/donutchart/donutchart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = donutchart
+SOURCES += main.cpp
diff --git a/examples/charts/donutchart/main.cpp b/examples/charts/donutchart/main.cpp
new file mode 100644
index 00000000..78b2a7c3
--- /dev/null
+++ b/examples/charts/donutchart/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 <QPieSeries>
+#include <QPieSlice>
+#include <QDebug>
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QPieSeries *series = new QPieSeries();
+ series->setHoleSize(0.35);
+ series->append("Protein 4.2%", 4.2);
+ QPieSlice *slice = series->append("Fat 15.6%", 15.6);
+ slice->setExploded();
+ slice->setLabelVisible();
+ series->append("Other 23.8%", 23.8);
+ series->append("Carbs 56.4%", 56.4);
+//![1]
+
+//![2]
+ QChartView *chartView = new QChartView();
+ chartView->setRenderHint(QPainter::Antialiasing);
+ chartView->chart()->setTitle("Donut with a lemon glaze (100g)");
+ chartView->chart()->addSeries(series);
+ chartView->chart()->legend()->setAlignment(Qt::AlignBottom);
+ chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
+ chartView->chart()->legend()->setFont(QFont("Arial", 7));
+//![2]
+
+//![3]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+//![3]
+
+ return a.exec();
+}
diff --git a/examples/charts/dynamicspline/chart.cpp b/examples/charts/dynamicspline/chart.cpp
new file mode 100644
index 00000000..4c7bc355
--- /dev/null
+++ b/examples/charts/dynamicspline/chart.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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 "chart.h"
+#include <QAbstractAxis>
+#include <QSplineSeries>
+#include <QValueAxis>
+#include <QTime>
+#include <QDebug>
+
+Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags):
+ QChart(QChart::ChartTypeCartesian, parent, wFlags),
+ m_series(0),
+ m_axis(new QValueAxis),
+ m_step(0),
+ m_x(5),
+ m_y(1)
+{
+ qsrand((uint) QTime::currentTime().msec());
+
+ QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
+ m_timer.setInterval(1000);
+
+ m_series = new QSplineSeries(this);
+ QPen green(Qt::red);
+ green.setWidth(3);
+ m_series->setPen(green);
+ m_series->append(m_x, m_y);
+
+ addSeries(m_series);
+ createDefaultAxes();
+ setAxisX(m_axis, m_series);
+ m_axis->setTickCount(5);
+ axisX()->setRange(0, 10);
+ axisY()->setRange(-5, 10);
+
+ m_timer.start();
+}
+
+Chart::~Chart()
+{
+
+}
+
+void Chart::handleTimeout()
+{
+ qreal x = plotArea().width() / m_axis->tickCount();
+ qreal y = (m_axis->max() - m_axis->min()) / m_axis->tickCount();
+ m_x += y;
+ m_y = qrand() % 5 - 2.5;
+ m_series->append(m_x, m_y);
+ scroll(x, 0);
+ if (m_x == 100)
+ m_timer.stop();
+}
diff --git a/examples/charts/dynamicspline/chart.h b/examples/charts/dynamicspline/chart.h
new file mode 100644
index 00000000..b6d5eb1c
--- /dev/null
+++ b/examples/charts/dynamicspline/chart.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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 CHART_H
+#define CHART_H
+
+#include <QChart>
+#include <QTimer>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QSplineSeries;
+class QValueAxis;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+//![1]
+class Chart: public QChart
+{
+ Q_OBJECT
+public:
+ Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ virtual ~Chart();
+
+public slots:
+ void handleTimeout();
+
+private:
+ QTimer m_timer;
+ QSplineSeries *m_series;
+ QStringList m_titles;
+ QValueAxis *m_axis;
+ qreal m_step;
+ qreal m_x;
+ qreal m_y;
+};
+//![1]
+
+#endif /* CHART_H */
diff --git a/examples/charts/dynamicspline/dynamicspline.pro b/examples/charts/dynamicspline/dynamicspline.pro
new file mode 100644
index 00000000..feb26895
--- /dev/null
+++ b/examples/charts/dynamicspline/dynamicspline.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = dynamicspline
+HEADERS += chart.h
+SOURCES += main.cpp chart.cpp
diff --git a/examples/charts/dynamicspline/main.cpp b/examples/charts/dynamicspline/main.cpp
new file mode 100644
index 00000000..00f18c2f
--- /dev/null
+++ b/examples/charts/dynamicspline/main.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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 "chart.h"
+#include <QChartView>
+#include <QApplication>
+#include <QMainWindow>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow window;
+ Chart *chart = new Chart;
+ chart->setTitle("Dynamic spline chart");
+ chart->legend()->hide();
+ chart->setAnimationOptions(QChart::AllAnimations);
+ QChartView chartView(chart);
+ chartView.setRenderHint(QPainter::Antialiasing);
+ window.setCentralWidget(&chartView);
+ window.resize(400, 300);
+ window.show();
+ return a.exec();
+}
diff --git a/examples/charts/examples.pri b/examples/charts/examples.pri
new file mode 100644
index 00000000..7b2eaaa7
--- /dev/null
+++ b/examples/charts/examples.pri
@@ -0,0 +1,17 @@
+
+INCLUDEPATH += ../../../include
+
+LIBS += -L$$OUT_PWD/../../../lib
+
+TEMPLATE = app
+
+QT += charts
+QT += core gui widgets
+
+contains(TARGET, qml.*) {
+ QT += qml quick
+}
+
+target.path = $$[QT_INSTALL_EXAMPLES]/charts/$$TARGET
+INSTALLS += target
+
diff --git a/examples/charts/horizontalbarchart/horizontalbarchart.pro b/examples/charts/horizontalbarchart/horizontalbarchart.pro
new file mode 100644
index 00000000..61ec088e
--- /dev/null
+++ b/examples/charts/horizontalbarchart/horizontalbarchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = horizontalbarchart
+SOURCES += main.cpp
diff --git a/examples/charts/horizontalbarchart/main.cpp b/examples/charts/horizontalbarchart/main.cpp
new file mode 100644
index 00000000..725aa127
--- /dev/null
+++ b/examples/charts/horizontalbarchart/main.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+#include <QValueAxis>
+#include <QHorizontalBarSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QHorizontalBarSeries *series = new QHorizontalBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple horizontal barchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axisY = new QBarCategoryAxis();
+ axisY->append(categories);
+ chart->setAxisY(axisY, series);
+ QValueAxis *axisX = new QValueAxis();
+ chart->setAxisX(axisX, series);
+ axisX->applyNiceNumbers();
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro b/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro
new file mode 100644
index 00000000..d6168695
--- /dev/null
+++ b/examples/charts/horizontalpercentbarchart/horizontalpercentbarchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = horizontalpercentbarchart
+SOURCES += main.cpp
diff --git a/examples/charts/horizontalpercentbarchart/main.cpp b/examples/charts/horizontalpercentbarchart/main.cpp
new file mode 100644
index 00000000..d8adab49
--- /dev/null
+++ b/examples/charts/horizontalpercentbarchart/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+#include <QHorizontalPercentBarSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple horizontal percent barchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisY(axis, series);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro b/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro
new file mode 100644
index 00000000..5c08d212
--- /dev/null
+++ b/examples/charts/horizontalstackedbarchart/horizontalstackedbarchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = horizontalstackedbarchart
+SOURCES += main.cpp
diff --git a/examples/charts/horizontalstackedbarchart/main.cpp b/examples/charts/horizontalstackedbarchart/main.cpp
new file mode 100644
index 00000000..13df0cdf
--- /dev/null
+++ b/examples/charts/horizontalstackedbarchart/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+#include <QHorizontalStackedBarSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple horizontal stacked barchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisY(axis, series);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/legend/legend.pro b/examples/charts/legend/legend.pro
new file mode 100644
index 00000000..5e22fb2a
--- /dev/null
+++ b/examples/charts/legend/legend.pro
@@ -0,0 +1,10 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = legend
+SOURCES += main.cpp \
+ mainwidget.cpp
+
+HEADERS += \
+ mainwidget.h
diff --git a/examples/charts/legend/main.cpp b/examples/charts/legend/main.cpp
new file mode 100644
index 00000000..64d3903b
--- /dev/null
+++ b/examples/charts/legend/main.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+
+#include <QApplication>
+#include <QMainWindow>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ MainWidget w;
+ w.resize(720, 480);
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/legend/mainwidget.cpp b/examples/charts/legend/mainwidget.cpp
new file mode 100644
index 00000000..32bc2ae9
--- /dev/null
+++ b/examples/charts/legend/mainwidget.cpp
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+#include <QChart>
+#include <QChartView>
+#include <QPushButton>
+#include <QLabel>
+#include <QDebug>
+#include <QBarSet>
+#include <QBarSeries>
+#include <QLegend>
+#include <QFormLayout>
+
+QT_CHARTS_USE_NAMESPACE
+
+MainWidget::MainWidget(QWidget *parent) :
+ QWidget(parent)
+{
+ // Create buttons for ui
+ m_buttonLayout = new QGridLayout();
+ QPushButton *detachLegendButton = new QPushButton("Toggle attached");
+ connect(detachLegendButton, SIGNAL(clicked()), this, SLOT(toggleAttached()));
+ m_buttonLayout->addWidget(detachLegendButton, 0, 0);
+
+ QPushButton *addSetButton = new QPushButton("add barset");
+ connect(addSetButton, SIGNAL(clicked()), this, SLOT(addBarset()));
+ m_buttonLayout->addWidget(addSetButton, 2, 0);
+ QPushButton *removeBarsetButton = new QPushButton("remove barset");
+ connect(removeBarsetButton, SIGNAL(clicked()), this, SLOT(removeBarset()));
+ m_buttonLayout->addWidget(removeBarsetButton, 3, 0);
+
+ QPushButton *alignButton = new QPushButton("Align (Bottom)");
+ connect(alignButton, SIGNAL(clicked()), this, SLOT(setLegendAlignment()));
+ m_buttonLayout->addWidget(alignButton, 4, 0);
+
+ QPushButton *boldButton = new QPushButton("Toggle bold");
+ connect(boldButton, SIGNAL(clicked()), this, SLOT(toggleBold()));
+ m_buttonLayout->addWidget(boldButton, 8, 0);
+
+ QPushButton *italicButton = new QPushButton("Toggle italic");
+ connect(italicButton, SIGNAL(clicked()), this, SLOT(toggleItalic()));
+ m_buttonLayout->addWidget(italicButton, 9, 0);
+
+ m_legendPosX = new QDoubleSpinBox();
+ m_legendPosY = new QDoubleSpinBox();
+ m_legendWidth = new QDoubleSpinBox();
+ m_legendHeight = new QDoubleSpinBox();
+
+ connect(m_legendPosX, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout()));
+ connect(m_legendPosY, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout()));
+ connect(m_legendWidth, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout()));
+ connect(m_legendHeight, SIGNAL(valueChanged(double)), this, SLOT(updateLegendLayout()));
+
+ QFormLayout *legendLayout = new QFormLayout();
+ legendLayout->addRow("HPos", m_legendPosX);
+ legendLayout->addRow("VPos", m_legendPosY);
+ legendLayout->addRow("Width", m_legendWidth);
+ legendLayout->addRow("Height", m_legendHeight);
+ m_legendSettings = new QGroupBox("Detached legend");
+ m_legendSettings->setLayout(legendLayout);
+ m_buttonLayout->addWidget(m_legendSettings);
+ m_legendSettings->setVisible(false);
+
+ // Create chart view with the chart
+ m_chart = new QChart();
+ m_chartView = new QChartView(m_chart, this);
+
+ // Create spinbox to modify font size
+ m_fontSize = new QDoubleSpinBox();
+ m_fontSize->setValue(m_chart->legend()->font().pointSizeF());
+ connect(m_fontSize, SIGNAL(valueChanged(double)), this, SLOT(fontSizeChanged()));
+
+ QFormLayout *fontLayout = new QFormLayout();
+ fontLayout->addRow("Legend font size", m_fontSize);
+
+ // Create layout for grid and detached legend
+ m_mainLayout = new QGridLayout();
+ m_mainLayout->addLayout(m_buttonLayout, 0, 0);
+ m_mainLayout->addLayout(fontLayout, 1, 0);
+ m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1);
+ setLayout(m_mainLayout);
+
+ createSeries();
+}
+
+void MainWidget::createSeries()
+{
+ m_series = new QBarSeries();
+ addBarset();
+ addBarset();
+ addBarset();
+ addBarset();
+
+ m_chart->addSeries(m_series);
+ m_chart->setTitle("Legend detach example");
+ m_chart->createDefaultAxes();
+//![1]
+ m_chart->legend()->setVisible(true);
+ m_chart->legend()->setAlignment(Qt::AlignBottom);
+//![1]
+
+ m_chartView->setRenderHint(QPainter::Antialiasing);
+}
+
+void MainWidget::showLegendSpinbox()
+{
+ m_legendSettings->setVisible(true);
+ QRectF chartViewRect = m_chartView->rect();
+
+ m_legendPosX->setMinimum(0);
+ m_legendPosX->setMaximum(chartViewRect.width());
+ m_legendPosX->setValue(150);
+
+ m_legendPosY->setMinimum(0);
+ m_legendPosY->setMaximum(chartViewRect.height());
+ m_legendPosY->setValue(150);
+
+ m_legendWidth->setMinimum(0);
+ m_legendWidth->setMaximum(chartViewRect.width());
+ m_legendWidth->setValue(150);
+
+ m_legendHeight->setMinimum(0);
+ m_legendHeight->setMaximum(chartViewRect.height());
+ m_legendHeight->setValue(75);
+}
+
+void MainWidget::hideLegendSpinbox()
+{
+ m_legendSettings->setVisible(false);
+}
+
+
+void MainWidget::toggleAttached()
+{
+ QLegend *legend = m_chart->legend();
+ if (legend->isAttachedToChart()) {
+ //![2]
+ legend->detachFromChart();
+ m_chart->legend()->setBackgroundVisible(true);
+ m_chart->legend()->setBrush(QBrush(QColor(128, 128, 128, 128)));
+ m_chart->legend()->setPen(QPen(QColor(192, 192, 192, 192)));
+ //![2]
+ showLegendSpinbox();
+ updateLegendLayout();
+ } else {
+ //![3]
+ legend->attachToChart();
+ legend->setBackgroundVisible(false);
+ //![3]
+ hideLegendSpinbox();
+ }
+ update();
+}
+
+void MainWidget::addBarset()
+{
+ QBarSet *barSet = new QBarSet(QString("set ") + QString::number(m_series->count()));
+ qreal delta = m_series->count() * 0.1;
+ *barSet << 1 + delta << 2 + delta << 3 + delta << 4 + delta;
+ m_series->append(barSet);
+}
+
+void MainWidget::removeBarset()
+{
+ QList<QBarSet *> sets = m_series->barSets();
+ if (sets.count() > 0) {
+ m_series->remove(sets.at(sets.count() - 1));
+ }
+}
+
+void MainWidget::setLegendAlignment()
+{
+ QPushButton *button = qobject_cast<QPushButton *>(sender());
+
+ switch (m_chart->legend()->alignment()) {
+ case Qt::AlignTop:
+ m_chart->legend()->setAlignment(Qt::AlignLeft);
+ if (button)
+ button->setText("Align (Left)");
+ break;
+ case Qt::AlignLeft:
+ m_chart->legend()->setAlignment(Qt::AlignBottom);
+ if (button)
+ button->setText("Align (Bottom)");
+ break;
+ case Qt::AlignBottom:
+ m_chart->legend()->setAlignment(Qt::AlignRight);
+ if (button)
+ button->setText("Align (Right)");
+ break;
+ default:
+ if (button)
+ button->setText("Align (Top)");
+ m_chart->legend()->setAlignment(Qt::AlignTop);
+ break;
+ }
+}
+
+void MainWidget::toggleBold()
+{
+ QFont font = m_chart->legend()->font();
+ font.setBold(!font.bold());
+ m_chart->legend()->setFont(font);
+}
+
+void MainWidget::toggleItalic()
+{
+ QFont font = m_chart->legend()->font();
+ font.setItalic(!font.italic());
+ m_chart->legend()->setFont(font);
+}
+
+void MainWidget::fontSizeChanged()
+{
+ QFont font = m_chart->legend()->font();
+ font.setPointSizeF(m_fontSize->value());
+ m_chart->legend()->setFont(font);
+}
+
+void MainWidget::updateLegendLayout()
+{
+//![4]
+ m_chart->legend()->setGeometry(QRectF(m_legendPosX->value(),
+ m_legendPosY->value(),
+ m_legendWidth->value(),
+ m_legendHeight->value()));
+ m_chart->legend()->update();
+//![4]
+}
diff --git a/examples/charts/legend/mainwidget.h b/examples/charts/legend/mainwidget.h
new file mode 100644
index 00000000..3a24d674
--- /dev/null
+++ b/examples/charts/legend/mainwidget.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include "qchartglobal.h"
+#include "qchart.h"
+#include "qchartview.h"
+#include <QWidget>
+#include <QGraphicsWidget>
+#include <QGridLayout>
+#include <QGraphicsGridLayout>
+#include <QDoubleSpinBox>
+#include <QGroupBox>
+#include <QBarSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class MainWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit MainWidget(QWidget *parent = 0);
+ void createSeries();
+ void showLegendSpinbox();
+ void hideLegendSpinbox();
+
+public Q_SLOTS:
+ void toggleAttached();
+ void addBarset();
+ void removeBarset();
+
+ void setLegendAlignment();
+
+ void toggleBold();
+ void toggleItalic();
+ void fontSizeChanged();
+
+ void updateLegendLayout();
+
+private:
+ QChart *m_chart;
+ QBarSeries *m_series;
+
+ QChartView *m_chartView;
+ QGridLayout *m_mainLayout;
+ QGridLayout *m_buttonLayout;
+ QGridLayout *m_fontLayout;
+
+ QDoubleSpinBox *m_fontSize;
+
+ // For detached layout
+ QGroupBox *m_legendSettings;
+ QDoubleSpinBox *m_legendPosX;
+ QDoubleSpinBox *m_legendPosY;
+ QDoubleSpinBox *m_legendWidth;
+ QDoubleSpinBox *m_legendHeight;
+};
+
+#endif // MAINWIDGET_H
diff --git a/examples/charts/legendmarkers/legendmarkers.pro b/examples/charts/legendmarkers/legendmarkers.pro
new file mode 100644
index 00000000..f79bdba4
--- /dev/null
+++ b/examples/charts/legendmarkers/legendmarkers.pro
@@ -0,0 +1,10 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = legendmarkers
+SOURCES += main.cpp \
+ mainwidget.cpp
+
+HEADERS += \
+ mainwidget.h
diff --git a/examples/charts/legendmarkers/main.cpp b/examples/charts/legendmarkers/main.cpp
new file mode 100644
index 00000000..f627e496
--- /dev/null
+++ b/examples/charts/legendmarkers/main.cpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+
+#include <QApplication>
+#include <QMainWindow>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ MainWidget w;
+ w.resize(720, 480);
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/legendmarkers/mainwidget.cpp b/examples/charts/legendmarkers/mainwidget.cpp
new file mode 100644
index 00000000..f71e7a61
--- /dev/null
+++ b/examples/charts/legendmarkers/mainwidget.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+#include <QChart>
+#include <QChartView>
+#include <QPushButton>
+#include <QLabel>
+#include <QDebug>
+#include <QLegend>
+#include <QFormLayout>
+#include <QLegendMarker>
+#include <QLineSeries>
+#include <QXYLegendMarker>
+#include <qmath.h>
+
+QT_CHARTS_USE_NAMESPACE
+
+MainWidget::MainWidget(QWidget *parent) :
+ QWidget(parent)
+{
+ // Create chart view with the chart
+ m_chart = new QChart();
+ m_chartView = new QChartView(m_chart, this);
+
+ // Create layout for grid and detached legend
+ m_mainLayout = new QGridLayout();
+ m_mainLayout->addWidget(m_chartView, 0, 1, 3, 1);
+ setLayout(m_mainLayout);
+
+ // Add few series
+ addSeries();
+ addSeries();
+ addSeries();
+ addSeries();
+
+ connectMarkers();
+
+ // Set the title and show legend
+ m_chart->setTitle("Legendmarker example (click on legend)");
+ m_chart->legend()->setVisible(true);
+ m_chart->legend()->setAlignment(Qt::AlignBottom);
+
+ m_chartView->setRenderHint(QPainter::Antialiasing);
+}
+
+void MainWidget::addSeries()
+{
+ QLineSeries *series = new QLineSeries();
+ m_series.append(series);
+
+ series->setName(QString("line " + QString::number(m_series.count())));
+
+ // Make some sine wave for data
+ QList<QPointF> data;
+ int offset = m_chart->series().count();
+ for (int i = 0; i < 360; i++) {
+ qreal x = offset * 20 + i;
+ data.append(QPointF(i, qSin(2.0 * 3.141592 * x / 360.0)));
+ }
+
+ series->append(data);
+ m_chart->addSeries(series);
+
+ if (m_series.count() == 1) {
+ m_chart->createDefaultAxes();
+ }
+}
+
+void MainWidget::removeSeries()
+{
+ // Remove last series from chart
+ if (m_series.count() > 0) {
+ QLineSeries *series = m_series.last();
+ m_chart->removeSeries(series);
+ m_series.removeLast();
+ delete series;
+ }
+}
+
+void MainWidget::connectMarkers()
+{
+//![1]
+ // Connect all markers to handler
+ foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
+ // Disconnect possible existing connection to avoid multiple connections
+ QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
+ QObject::connect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
+ }
+//![1]
+}
+
+void MainWidget::disconnectMarkers()
+{
+//![2]
+ foreach (QLegendMarker* marker, m_chart->legend()->markers()) {
+ QObject::disconnect(marker, SIGNAL(clicked()), this, SLOT(handleMarkerClicked()));
+ }
+//![2]
+}
+
+void MainWidget::handleMarkerClicked()
+{
+//![3]
+ QLegendMarker* marker = qobject_cast<QLegendMarker*> (sender());
+ Q_ASSERT(marker);
+//![3]
+
+//![4]
+ switch (marker->type())
+//![4]
+ {
+ case QLegendMarker::LegendMarkerTypeXY:
+ {
+//![5]
+ // Toggle visibility of series
+ marker->series()->setVisible(!marker->series()->isVisible());
+
+ // Turn legend marker back to visible, since hiding series also hides the marker
+ // and we don't want it to happen now.
+ marker->setVisible(true);
+//![5]
+
+//![6]
+ // Dim the marker, if series is not visible
+ qreal alpha = 1.0;
+
+ if (!marker->series()->isVisible()) {
+ alpha = 0.5;
+ }
+
+ QColor color;
+ QBrush brush = marker->labelBrush();
+ color = brush.color();
+ color.setAlphaF(alpha);
+ brush.setColor(color);
+ marker->setLabelBrush(brush);
+
+ brush = marker->brush();
+ color = brush.color();
+ color.setAlphaF(alpha);
+ brush.setColor(color);
+ marker->setBrush(brush);
+
+ QPen pen = marker->pen();
+ color = pen.color();
+ color.setAlphaF(alpha);
+ pen.setColor(color);
+ marker->setPen(pen);
+
+//![6]
+ break;
+ }
+ default:
+ {
+ qDebug() << "Unknown marker type";
+ break;
+ }
+ }
+}
diff --git a/examples/charts/legendmarkers/mainwidget.h b/examples/charts/legendmarkers/mainwidget.h
new file mode 100644
index 00000000..350808a2
--- /dev/null
+++ b/examples/charts/legendmarkers/mainwidget.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include "qchartglobal.h"
+#include "qchart.h"
+#include "qchartview.h"
+#include <QWidget>
+#include <QGraphicsWidget>
+#include <QGridLayout>
+#include <QGraphicsGridLayout>
+#include <QDoubleSpinBox>
+#include <QGroupBox>
+#include <QLineSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class MainWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit MainWidget(QWidget *parent = 0);
+
+public slots:
+ void addSeries();
+ void removeSeries();
+ void connectMarkers();
+ void disconnectMarkers();
+
+ void handleMarkerClicked();
+
+private:
+
+ QChart *m_chart;
+ QList<QLineSeries *> m_series;
+
+ QChartView *m_chartView;
+ QGridLayout *m_mainLayout;
+ QGridLayout *m_fontLayout;
+
+};
+
+#endif // MAINWIDGET_H
diff --git a/examples/charts/lineandbar/lineandbar.pro b/examples/charts/lineandbar/lineandbar.pro
new file mode 100644
index 00000000..dd94abd5
--- /dev/null
+++ b/examples/charts/lineandbar/lineandbar.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = lineandbar
+SOURCES += main.cpp
diff --git a/examples/charts/lineandbar/main.cpp b/examples/charts/lineandbar/main.cpp
new file mode 100644
index 00000000..264d5829
--- /dev/null
+++ b/examples/charts/lineandbar/main.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLineSeries>
+#include <QLegend>
+#include <QBarCategoryAxis>
+#include <QValueAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Sam");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QBarSeries *barseries = new QBarSeries();
+ barseries->append(set0);
+ barseries->append(set1);
+ barseries->append(set2);
+ barseries->append(set3);
+ barseries->append(set4);
+//![2]
+
+//![8]
+ QLineSeries *lineseries = new QLineSeries();
+ lineseries->setName("trend");
+ lineseries->append(QPoint(0, 4));
+ lineseries->append(QPoint(1, 15));
+ lineseries->append(QPoint(2, 20));
+ lineseries->append(QPoint(3, 4));
+ lineseries->append(QPoint(4, 12));
+ lineseries->append(QPoint(5, 17));
+//![8]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(barseries);
+ chart->addSeries(lineseries);
+ chart->setTitle("Line and barchart example");
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axisX = new QBarCategoryAxis();
+ axisX->append(categories);
+ chart->setAxisX(axisX, lineseries);
+ chart->setAxisX(axisX, barseries);
+ axisX->setRange(QString("Jan"), QString("Jun"));
+
+ QValueAxis *axisY = new QValueAxis();
+ chart->setAxisY(axisY, lineseries);
+ chart->setAxisY(axisY, barseries);
+ axisY->setRange(0, 20);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(440, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/linechart/linechart.pro b/examples/charts/linechart/linechart.pro
new file mode 100644
index 00000000..d3eb640a
--- /dev/null
+++ b/examples/charts/linechart/linechart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = linechart
+SOURCES += main.cpp
diff --git a/examples/charts/linechart/main.cpp b/examples/charts/linechart/main.cpp
new file mode 100644
index 00000000..c0040e51
--- /dev/null
+++ b/examples/charts/linechart/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QLineSeries *series = new QLineSeries();
+//![1]
+
+//![2]
+ series->append(0, 6);
+ series->append(2, 4);
+ series->append(3, 8);
+ series->append(7, 4);
+ series->append(10, 5);
+ *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+ 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();
+//![5]
+
+ return a.exec();
+}
diff --git a/examples/charts/logvalueaxis/logvalueaxis.pro b/examples/charts/logvalueaxis/logvalueaxis.pro
new file mode 100644
index 00000000..ede43079
--- /dev/null
+++ b/examples/charts/logvalueaxis/logvalueaxis.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = logvalueaxis
+SOURCES += main.cpp
diff --git a/examples/charts/logvalueaxis/main.cpp b/examples/charts/logvalueaxis/main.cpp
new file mode 100644
index 00000000..73591ae3
--- /dev/null
+++ b/examples/charts/logvalueaxis/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+#include <QValueAxis>
+#include <QLogValueAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ //![1]
+ QLineSeries *series = new QLineSeries();
+ *series << QPointF(1, 1) << QPointF(2, 73) << QPointF(3, 268) << QPointF(4, 17) << QPointF(5, 4325) << QPointF(6, 723);
+ //![1]
+
+ //![2]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->legend()->hide();
+ chart->setTitle("Logarithmic axis example");
+ //![2]
+
+ //![3]
+ QValueAxis *axisX = new QValueAxis;
+ axisX->setTitleText("Data point");
+ axisX->setTickCount(6);
+ axisX->setLabelFormat("%i");
+ chart->addAxis(axisX, Qt::AlignBottom);
+ series->attachAxis(axisX);
+
+ QLogValueAxis *axisY = new QLogValueAxis;
+ axisY->setLabelFormat("%g");
+ axisY->setTitleText("Values");
+ axisY->setBase(8);
+ chart->addAxis(axisY, Qt::AlignLeft);
+ series->attachAxis(axisY);
+ //![3]
+
+ //![4]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ //![4]
+
+ //![5]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+ //![5]
+
+ return a.exec();
+}
diff --git a/examples/charts/modeldata/customtablemodel.cpp b/examples/charts/modeldata/customtablemodel.cpp
new file mode 100644
index 00000000..2bec3c98
--- /dev/null
+++ b/examples/charts/modeldata/customtablemodel.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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 "customtablemodel.h"
+#include <QVector>
+#include <QTime>
+#include <QRect>
+#include <QColor>
+
+CustomTableModel::CustomTableModel(QObject *parent) :
+ QAbstractTableModel(parent)
+{
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ m_columnCount = 4;
+ m_rowCount = 15;
+
+ // m_data
+ for (int i = 0; i < m_rowCount; i++) {
+ QVector<qreal>* dataVec = new QVector<qreal>(m_columnCount);
+ for (int k = 0; k < dataVec->size(); k++) {
+ if (k % 2 == 0)
+ dataVec->replace(k, i * 50 + qrand() % 20);
+ else
+ dataVec->replace(k, qrand() % 100);
+ }
+ m_data.append(dataVec);
+ }
+}
+
+int CustomTableModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_data.count();
+}
+
+int CustomTableModel::columnCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_columnCount;
+}
+
+QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal) {
+ if (section % 2 == 0)
+ return "x";
+ else
+ return "y";
+ } else {
+ return QString("%1").arg(section + 1);
+ }
+}
+
+QVariant CustomTableModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::DisplayRole) {
+ return m_data[index.row()]->at(index.column());
+ } else if (role == Qt::EditRole) {
+ return m_data[index.row()]->at(index.column());
+ } else if (role == Qt::BackgroundRole) {
+ foreach (QRect rect, m_mapping) {
+ if (rect.contains(index.column(), index.row()))
+ return QColor(m_mapping.key(rect));
+ }
+ // cell not mapped return white color
+ return QColor(Qt::white);
+ }
+ return QVariant();
+}
+
+bool CustomTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+ m_data[index.row()]->replace(index.column(), value.toDouble());
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+Qt::ItemFlags CustomTableModel::flags(const QModelIndex &index) const
+{
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+
+void CustomTableModel::addMapping(QString color, QRect area)
+{
+ m_mapping.insertMulti(color, area);
+}
diff --git a/examples/charts/modeldata/customtablemodel.h b/examples/charts/modeldata/customtablemodel.h
new file mode 100644
index 00000000..755f4c7d
--- /dev/null
+++ b/examples/charts/modeldata/customtablemodel.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 CUSTOMTABLEMODEL_H
+#define CUSTOMTABLEMODEL_H
+
+#include <QAbstractTableModel>
+#include <QHash>
+#include <QRect>
+
+class CustomTableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit CustomTableModel(QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void addMapping(QString color, QRect area);
+ void clearMapping() { m_mapping.clear(); }
+
+private:
+ QList<QVector<qreal> * > m_data;
+ QHash<QString, QRect> m_mapping;
+ int m_columnCount;
+ int m_rowCount;
+};
+
+#endif // CUSTOMTABLEMODEL_H
diff --git a/examples/charts/modeldata/main.cpp b/examples/charts/modeldata/main.cpp
new file mode 100644
index 00000000..bf0b384b
--- /dev/null
+++ b/examples/charts/modeldata/main.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** 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 "tablewidget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ TableWidget w;
+ w.show();
+ return a.exec();
+}
diff --git a/examples/charts/modeldata/modeldata.pro b/examples/charts/modeldata/modeldata.pro
new file mode 100644
index 00000000..7c302bd9
--- /dev/null
+++ b/examples/charts/modeldata/modeldata.pro
@@ -0,0 +1,16 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += core gui
+
+TARGET = modeldata
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ tablewidget.cpp \
+ customtablemodel.cpp
+
+HEADERS += tablewidget.h \
+ customtablemodel.h
diff --git a/examples/charts/modeldata/tablewidget.cpp b/examples/charts/modeldata/tablewidget.cpp
new file mode 100644
index 00000000..5d50dd70
--- /dev/null
+++ b/examples/charts/modeldata/tablewidget.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 "tablewidget.h"
+#include "customtablemodel.h"
+#include <QGridLayout>
+#include <QTableView>
+#include <QChart>
+#include <QChartView>
+#include <QLineSeries>
+#include <QVXYModelMapper>
+#include <QHeaderView>
+
+QT_CHARTS_USE_NAMESPACE
+
+TableWidget::TableWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ // create simple model for storing data
+ // user's table data model
+ //! [1]
+ CustomTableModel *model = new CustomTableModel;
+ //! [1]
+
+ //! [2]
+ // create table view and add model to it
+ QTableView *tableView = new QTableView;
+ tableView->setModel(model);
+ tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ //! [2]
+
+ //! [3]
+ QChart *chart = new QChart;
+ chart->setAnimationOptions(QChart::AllAnimations);
+ //! [3]
+
+ // series 1
+ //! [4]
+ QLineSeries *series = new QLineSeries;
+ series->setName("Line 1");
+ QVXYModelMapper *mapper = new QVXYModelMapper(this);
+ mapper->setXColumn(0);
+ mapper->setYColumn(1);
+ mapper->setSeries(series);
+ mapper->setModel(model);
+ chart->addSeries(series);
+ //! [4]
+
+ //! [5]
+ // for storing color hex from the series
+ QString seriesColorHex = "#000000";
+
+ // get the color of the series and use it for showing the mapped area
+ seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
+ model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount()));
+ //! [5]
+
+
+ // series 2
+ //! [6]
+ series = new QLineSeries;
+ series->setName("Line 2");
+
+ mapper = new QVXYModelMapper(this);
+ mapper->setXColumn(2);
+ mapper->setYColumn(3);
+ mapper->setSeries(series);
+ mapper->setModel(model);
+ chart->addSeries(series);
+ //! [6]
+
+ //! [7]
+ // get the color of the series and use it for showing the mapped area
+ seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper();
+ model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount()));
+ //! [7]
+
+ //! [8]
+ chart->createDefaultAxes();
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ chartView->setMinimumSize(640, 480);
+ //! [8]
+
+ //! [9]
+ // create main layout
+ QGridLayout *mainLayout = new QGridLayout;
+ mainLayout->addWidget(tableView, 1, 0);
+ mainLayout->addWidget(chartView, 1, 1);
+ mainLayout->setColumnStretch(1, 1);
+ mainLayout->setColumnStretch(0, 0);
+ setLayout(mainLayout);
+ //! [9]
+}
diff --git a/examples/charts/modeldata/tablewidget.h b/examples/charts/modeldata/tablewidget.h
new file mode 100644
index 00000000..3846cc11
--- /dev/null
+++ b/examples/charts/modeldata/tablewidget.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** 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 TABLEWIDGET_H
+#define TABLEWIDGET_H
+
+#include <QWidget>
+
+class TableWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TableWidget(QWidget *parent = 0);
+};
+
+#endif // TABLEWIDGET_H
diff --git a/examples/charts/multiaxis/main.cpp b/examples/charts/multiaxis/main.cpp
new file mode 100644
index 00000000..b6b53e88
--- /dev/null
+++ b/examples/charts/multiaxis/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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 <QLineSeries>
+#include <QSplineSeries>
+#include <QValueAxis>
+#include <QCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ //![1]
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->setTitle("Multiaxis chart example");
+ //![1]
+
+ //![2]
+ QValueAxis *axisX = new QValueAxis;
+ axisX->setTickCount(10);
+ chart->addAxis(axisX, Qt::AlignBottom);
+ //![2]
+
+ //![3]
+ QSplineSeries *series = new QSplineSeries;
+ *series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5);
+ chart->addSeries(series);
+
+ QValueAxis *axisY = new QValueAxis;
+ axisY->setLinePenColor(series->pen().color());
+
+ chart->addAxis(axisY, Qt::AlignLeft);
+ series->attachAxis(axisX);
+ series->attachAxis(axisY);
+ //![3]
+
+ //![4]
+ series = new QSplineSeries;
+ *series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5)
+ << QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17);
+ chart->addSeries(series);
+
+ QCategoryAxis *axisY3 = new QCategoryAxis;
+ axisY3->append("Low", 5);
+ axisY3->append("Medium", 12);
+ axisY3->append("High", 17);
+ axisY3->setLinePenColor(series->pen().color());
+ axisY3->setGridLinePen((series->pen()));
+
+ chart->addAxis(axisY3, Qt::AlignRight);
+ series->attachAxis(axisX);
+ series->attachAxis(axisY3);
+ //![4]
+
+ //![5]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ //![5]
+
+ //![6]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(800, 600);
+ window.show();
+ //![6]
+
+ return a.exec();
+}
+
diff --git a/examples/charts/multiaxis/multiaxis.pro b/examples/charts/multiaxis/multiaxis.pro
new file mode 100644
index 00000000..33de57cb
--- /dev/null
+++ b/examples/charts/multiaxis/multiaxis.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = multiaxis
+SOURCES += main.cpp
diff --git a/examples/charts/nesteddonuts/main.cpp b/examples/charts/nesteddonuts/main.cpp
new file mode 100644
index 00000000..0b833a83
--- /dev/null
+++ b/examples/charts/nesteddonuts/main.cpp
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** 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 "widget.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ return a.exec();
+}
diff --git a/examples/charts/nesteddonuts/nesteddonuts.pro b/examples/charts/nesteddonuts/nesteddonuts.pro
new file mode 100644
index 00000000..fadab0cd
--- /dev/null
+++ b/examples/charts/nesteddonuts/nesteddonuts.pro
@@ -0,0 +1,8 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = nesteddonuts
+SOURCES += main.cpp\
+ widget.cpp
+HEADERS += widget.h
diff --git a/examples/charts/nesteddonuts/widget.cpp b/examples/charts/nesteddonuts/widget.cpp
new file mode 100644
index 00000000..e11c4c7c
--- /dev/null
+++ b/examples/charts/nesteddonuts/widget.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** 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 "widget.h"
+#include <QChartView>
+#include <QChart>
+#include <QLegend>
+#include <QPieSeries>
+#include <QPieSlice>
+#include <QTime>
+#include <QGridLayout>
+#include <QTimer>
+
+QT_CHARTS_USE_NAMESPACE
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+ setMinimumSize(800, 600);
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ //! [1]
+ QChartView *chartView = new QChartView;
+ chartView->setRenderHint(QPainter::Antialiasing);
+ QChart *chart = chartView->chart();
+ chart->legend()->setVisible(false);
+ chart->setTitle("Nested donuts demo");
+ chart->setAnimationOptions(QChart::AllAnimations);
+ //! [1]
+
+ //! [2]
+ qreal minSize = 0.1;
+ qreal maxSize = 0.9;
+ int donutCount = 5;
+ //! [2]
+
+ //! [3]
+ for (int i = 0; i < donutCount; i++) {
+ QPieSeries *donut = new QPieSeries;
+ int sliceCount = 3 + qrand() % 3;
+ for (int j = 0; j < sliceCount; j++) {
+ qreal value = 100 + qrand() % 100;
+ QPieSlice *slice = new QPieSlice(QString("%1").arg(value), value);
+ slice->setLabelVisible(true);
+ slice->setLabelColor(Qt::white);
+ slice->setLabelPosition(QPieSlice::LabelInsideTangential);
+ connect(slice, SIGNAL(hovered(bool)), this, SLOT(explodeSlice(bool)));
+ donut->append(slice);
+ donut->setHoleSize(minSize + i * (maxSize - minSize) / donutCount);
+ donut->setPieSize(minSize + (i + 1) * (maxSize - minSize) / donutCount);
+ }
+ m_donuts.append(donut);
+ chartView->chart()->addSeries(donut);
+ }
+ //! [3]
+
+ // create main layout
+ //! [4]
+ QGridLayout *mainLayout = new QGridLayout;
+ mainLayout->addWidget(chartView, 1, 1);
+ setLayout(mainLayout);
+ //! [4]
+
+ //! [5]
+ updateTimer = new QTimer(this);
+ connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateRotation()));
+ updateTimer->start(1250);
+ //! [5]
+}
+
+Widget::~Widget()
+{
+
+}
+
+//! [6]
+void Widget::updateRotation()
+{
+ for (int i = 0; i < m_donuts.count(); i++) {
+ QPieSeries *donut = m_donuts.at(i);
+ qreal phaseShift = -50 + qrand() % 100;
+ donut->setPieStartAngle(donut->pieStartAngle() + phaseShift);
+ donut->setPieEndAngle(donut->pieEndAngle() + phaseShift);
+ }
+}
+//! [6]
+
+//! [7]
+void Widget::explodeSlice(bool exploded)
+{
+ QPieSlice *slice = qobject_cast<QPieSlice *>(sender());
+ if (exploded) {
+ updateTimer->stop();
+ qreal sliceStartAngle = slice->startAngle();
+ qreal sliceEndAngle = slice->startAngle() + slice->angleSpan();
+
+ QPieSeries *donut = slice->series();
+ qreal seriesIndex = m_donuts.indexOf(donut);
+ for (int i = seriesIndex + 1; i < m_donuts.count(); i++) {
+ m_donuts.at(i)->setPieStartAngle(sliceEndAngle);
+ m_donuts.at(i)->setPieEndAngle(360 + sliceStartAngle);
+ }
+ } else {
+ for (int i = 0; i < m_donuts.count(); i++) {
+ m_donuts.at(i)->setPieStartAngle(0);
+ m_donuts.at(i)->setPieEndAngle(360);
+ }
+ updateTimer->start();
+ }
+ slice->setExploded(exploded);
+}
+//! [7]
diff --git a/examples/charts/nesteddonuts/widget.h b/examples/charts/nesteddonuts/widget.h
new file mode 100644
index 00000000..6d2b749c
--- /dev/null
+++ b/examples/charts/nesteddonuts/widget.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** 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 WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+#include <QPieSeries>
+
+class QTimer;
+
+QT_CHARTS_USE_NAMESPACE
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Widget(QWidget *parent = 0);
+ ~Widget();
+
+public slots:
+ void updateRotation();
+ void explodeSlice(bool exploded);
+
+private:
+ QList<QPieSeries *> m_donuts;
+ QTimer *updateTimer;
+};
+
+#endif // WIDGET_H
diff --git a/examples/charts/percentbarchart/main.cpp b/examples/charts/percentbarchart/main.cpp
new file mode 100644
index 00000000..15a68206
--- /dev/null
+++ b/examples/charts/percentbarchart/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 <QPercentBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QPercentBarSeries *series = new QPercentBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple percentbarchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisX(axis, series);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
+
diff --git a/examples/charts/percentbarchart/percentbarchart.pro b/examples/charts/percentbarchart/percentbarchart.pro
new file mode 100644
index 00000000..983159d1
--- /dev/null
+++ b/examples/charts/percentbarchart/percentbarchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = percentbarchart
+SOURCES += main.cpp
diff --git a/examples/charts/piechart/main.cpp b/examples/charts/piechart/main.cpp
new file mode 100644
index 00000000..5e7b4ef1
--- /dev/null
+++ b/examples/charts/piechart/main.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 <QPieSeries>
+#include <QPieSlice>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QPieSeries *series = new QPieSeries();
+ series->append("Jane", 1);
+ series->append("Joe", 2);
+ series->append("Andy", 3);
+ series->append("Barbara", 4);
+ series->append("Axel", 5);
+//![1]
+
+//![2]
+ QPieSlice *slice = series->slices().at(1);
+ slice->setExploded();
+ slice->setLabelVisible();
+ slice->setPen(QPen(Qt::darkGreen, 2));
+ slice->setBrush(Qt::green);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple piechart example");
+ chart->legend()->hide();
+//![3]
+
+//![4]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![4]
+
+//![5]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+//![5]
+
+ return a.exec();
+}
diff --git a/examples/charts/piechart/piechart.pro b/examples/charts/piechart/piechart.pro
new file mode 100644
index 00000000..7bd48514
--- /dev/null
+++ b/examples/charts/piechart/piechart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = piechart
+SOURCES += main.cpp
diff --git a/examples/charts/piechartcustomization/brushtool.cpp b/examples/charts/piechartcustomization/brushtool.cpp
new file mode 100644
index 00000000..08dff95a
--- /dev/null
+++ b/examples/charts/piechartcustomization/brushtool.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 "brushtool.h"
+#include <QPushButton>
+#include <QFormLayout>
+#include <QComboBox>
+#include <QColorDialog>
+
+BrushTool::BrushTool(QString title, QWidget *parent)
+ : QWidget(parent)
+{
+ setWindowTitle(title);
+ setWindowFlags(Qt::Tool);
+
+ m_colorButton = new QPushButton();
+ m_styleCombo = new QComboBox();
+ m_styleCombo->addItem("Nobrush", (int) Qt::NoBrush);
+ m_styleCombo->addItem("Solidpattern", (int) Qt::SolidPattern);
+ m_styleCombo->addItem("Dense1pattern", (int) Qt::Dense1Pattern);
+ m_styleCombo->addItem("Dense2attern", (int) Qt::Dense2Pattern);
+ m_styleCombo->addItem("Dense3Pattern", (int) Qt::Dense3Pattern);
+ m_styleCombo->addItem("Dense4Pattern", (int) Qt::Dense4Pattern);
+ m_styleCombo->addItem("Dense5Pattern", (int) Qt::Dense5Pattern);
+ m_styleCombo->addItem("Dense6Pattern", (int) Qt::Dense6Pattern);
+ m_styleCombo->addItem("Dense7Pattern", (int) Qt::Dense7Pattern);
+ m_styleCombo->addItem("HorPattern", (int) Qt::HorPattern);
+ m_styleCombo->addItem("VerPattern", (int) Qt::VerPattern);
+ m_styleCombo->addItem("CrossPattern", (int) Qt::CrossPattern);
+ m_styleCombo->addItem("BDiagPattern", (int) Qt::BDiagPattern);
+ m_styleCombo->addItem("FDiagPattern", (int) Qt::FDiagPattern);
+ m_styleCombo->addItem("DiagCrossPattern", (int) Qt::DiagCrossPattern);
+
+ QFormLayout *layout = new QFormLayout();
+ layout->addRow("Color", m_colorButton);
+ layout->addRow("Style", m_styleCombo);
+ setLayout(layout);
+
+ connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
+ connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle()));
+}
+
+void BrushTool::setBrush(QBrush brush)
+{
+ m_brush = brush;
+ m_colorButton->setText(m_brush.color().name());
+ m_styleCombo->setCurrentIndex(m_brush.style()); // index matches the enum
+}
+
+QBrush BrushTool::brush() const
+{
+ return m_brush;
+}
+
+QString BrushTool::name()
+{
+ return name(m_brush);
+}
+
+QString BrushTool::name(const QBrush &brush)
+{
+ return brush.color().name();
+}
+
+void BrushTool::showColorDialog()
+{
+ QColorDialog dialog(m_brush.color());
+ dialog.show();
+ dialog.exec();
+ m_brush.setColor(dialog.selectedColor());
+ m_colorButton->setText(m_brush.color().name());
+ emit changed();
+}
+
+void BrushTool::updateStyle()
+{
+ Qt::BrushStyle style = (Qt::BrushStyle) m_styleCombo->itemData(m_styleCombo->currentIndex()).toInt();
+ if (m_brush.style() != style) {
+ m_brush.setStyle(style);
+ emit changed();
+ }
+}
+
+#include "moc_brushtool.cpp"
diff --git a/examples/charts/piechartcustomization/brushtool.h b/examples/charts/piechartcustomization/brushtool.h
new file mode 100644
index 00000000..f6e31b72
--- /dev/null
+++ b/examples/charts/piechartcustomization/brushtool.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 BRUSHTOOL_H
+#define BRUSHTOOL_H
+
+#include <QWidget>
+#include <QBrush>
+
+class QPushButton;
+class QComboBox;
+
+class BrushTool : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit BrushTool(QString title, QWidget *parent = 0);
+ void setBrush(QBrush brush);
+ QBrush brush() const;
+ QString name();
+ static QString name(const QBrush &brush);
+
+Q_SIGNALS:
+ void changed();
+
+public Q_SLOTS:
+ void showColorDialog();
+ void updateStyle();
+
+private:
+ QBrush m_brush;
+ QPushButton *m_colorButton;
+ QComboBox *m_styleCombo;
+};
+
+#endif // BRUSHTOOL_H
diff --git a/examples/charts/piechartcustomization/customslice.cpp b/examples/charts/piechartcustomization/customslice.cpp
new file mode 100644
index 00000000..bbcd1492
--- /dev/null
+++ b/examples/charts/piechartcustomization/customslice.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 "customslice.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+CustomSlice::CustomSlice(QString label, qreal value)
+ : QPieSlice(label, value)
+{
+ connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool)));
+}
+
+QBrush CustomSlice::originalBrush()
+{
+ return m_originalBrush;
+}
+
+void CustomSlice::showHighlight(bool show)
+{
+ if (show) {
+ QBrush brush = this->brush();
+ m_originalBrush = brush;
+ brush.setColor(brush.color().lighter());
+ setBrush(brush);
+ } else {
+ setBrush(m_originalBrush);
+ }
+}
+
+#include "moc_customslice.cpp"
diff --git a/examples/charts/piechartcustomization/customslice.h b/examples/charts/piechartcustomization/customslice.h
new file mode 100644
index 00000000..4c8e81fa
--- /dev/null
+++ b/examples/charts/piechartcustomization/customslice.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** 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 CUSTOMSLICE_H
+#define CUSTOMSLICE_H
+
+#include <QPieSlice>
+
+QT_CHARTS_USE_NAMESPACE
+
+class CustomSlice : public QPieSlice
+{
+ Q_OBJECT
+
+public:
+ CustomSlice(QString label, qreal value);
+
+public:
+ QBrush originalBrush();
+
+public Q_SLOTS:
+ void showHighlight(bool show);
+
+private:
+ QBrush m_originalBrush;
+};
+
+#endif // CUSTOMSLICE_H
diff --git a/examples/charts/piechartcustomization/main.cpp b/examples/charts/piechartcustomization/main.cpp
new file mode 100644
index 00000000..f35fd0fc
--- /dev/null
+++ b/examples/charts/piechartcustomization/main.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+#include <QApplication>
+#include <QMainWindow>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow window;
+ MainWidget widget;
+ window.setCentralWidget(&widget);
+ window.resize(900, 600);
+ window.show();
+ return a.exec();
+}
diff --git a/examples/charts/piechartcustomization/mainwidget.cpp b/examples/charts/piechartcustomization/mainwidget.cpp
new file mode 100644
index 00000000..fb0ed05d
--- /dev/null
+++ b/examples/charts/piechartcustomization/mainwidget.cpp
@@ -0,0 +1,360 @@
+/****************************************************************************
+**
+** 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 "mainwidget.h"
+#include "customslice.h"
+#include "pentool.h"
+#include "brushtool.h"
+#include <QPushButton>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QLineEdit>
+#include <QGroupBox>
+#include <QDoubleSpinBox>
+#include <QFormLayout>
+#include <QFontDialog>
+#include <QChartView>
+#include <QPieSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+MainWidget::MainWidget(QWidget *parent)
+ : QWidget(parent),
+ m_slice(0)
+{
+ // create chart
+ QChart *chart = new QChart;
+ chart->setTitle("Piechart customization");
+ chart->setAnimationOptions(QChart::AllAnimations);
+
+ // create series
+ m_series = new QPieSeries();
+ *m_series << new CustomSlice("Slice 1", 10.0);
+ *m_series << new CustomSlice("Slice 2", 20.0);
+ *m_series << new CustomSlice("Slice 3", 30.0);
+ *m_series << new CustomSlice("Slice 4", 40.0);
+ *m_series << new CustomSlice("Slice 5", 50.0);
+ m_series->setLabelsVisible();
+ chart->addSeries(m_series);
+
+ connect(m_series, SIGNAL(clicked(QPieSlice*)), this, SLOT(handleSliceClicked(QPieSlice*)));
+
+ // chart settings
+ m_themeComboBox = new QComboBox();
+ m_themeComboBox->addItem("Light", QChart::ChartThemeLight);
+ m_themeComboBox->addItem("BlueCerulean", QChart::ChartThemeBlueCerulean);
+ m_themeComboBox->addItem("Dark", QChart::ChartThemeDark);
+ m_themeComboBox->addItem("BrownSand", QChart::ChartThemeBrownSand);
+ m_themeComboBox->addItem("BlueNcs", QChart::ChartThemeBlueNcs);
+ m_themeComboBox->addItem("High Contrast", QChart::ChartThemeHighContrast);
+ m_themeComboBox->addItem("Blue Icy", QChart::ChartThemeBlueIcy);
+ m_themeComboBox->addItem("Qt", QChart::ChartThemeQt);
+
+ m_aaCheckBox = new QCheckBox();
+ m_animationsCheckBox = new QCheckBox();
+ m_animationsCheckBox->setCheckState(Qt::Checked);
+
+ m_legendCheckBox = new QCheckBox();
+
+ QFormLayout *chartSettingsLayout = new QFormLayout();
+ chartSettingsLayout->addRow("Theme", m_themeComboBox);
+ chartSettingsLayout->addRow("Antialiasing", m_aaCheckBox);
+ chartSettingsLayout->addRow("Animations", m_animationsCheckBox);
+ chartSettingsLayout->addRow("Legend", m_legendCheckBox);
+ QGroupBox *chartSettings = new QGroupBox("Chart");
+ chartSettings->setLayout(chartSettingsLayout);
+
+ connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChartSettings()));
+ connect(m_aaCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
+ connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
+ connect(m_legendCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateChartSettings()));
+
+ // series settings
+ m_hPosition = new QDoubleSpinBox();
+ m_hPosition->setMinimum(0.0);
+ m_hPosition->setMaximum(1.0);
+ m_hPosition->setSingleStep(0.1);
+ m_hPosition->setValue(m_series->horizontalPosition());
+
+ m_vPosition = new QDoubleSpinBox();
+ m_vPosition->setMinimum(0.0);
+ m_vPosition->setMaximum(1.0);
+ m_vPosition->setSingleStep(0.1);
+ m_vPosition->setValue(m_series->verticalPosition());
+
+ m_sizeFactor = new QDoubleSpinBox();
+ m_sizeFactor->setMinimum(0.0);
+ m_sizeFactor->setMaximum(1.0);
+ m_sizeFactor->setSingleStep(0.1);
+ m_sizeFactor->setValue(m_series->pieSize());
+
+ m_startAngle = new QDoubleSpinBox();
+ m_startAngle->setMinimum(-720);
+ m_startAngle->setMaximum(720);
+ m_startAngle->setValue(m_series->pieStartAngle());
+ m_startAngle->setSingleStep(1);
+
+ m_endAngle = new QDoubleSpinBox();
+ m_endAngle->setMinimum(-720);
+ m_endAngle->setMaximum(720);
+ m_endAngle->setValue(m_series->pieEndAngle());
+ m_endAngle->setSingleStep(1);
+
+ m_holeSize = new QDoubleSpinBox();
+ m_holeSize->setMinimum(0.0);
+ m_holeSize->setMaximum(1.0);
+ m_holeSize->setSingleStep(0.1);
+ m_holeSize->setValue(m_series->holeSize());
+
+ QPushButton *appendSlice = new QPushButton("Append slice");
+ QPushButton *insertSlice = new QPushButton("Insert slice");
+ QPushButton *removeSlice = new QPushButton("Remove selected slice");
+
+ QFormLayout *seriesSettingsLayout = new QFormLayout();
+ seriesSettingsLayout->addRow("Horizontal position", m_hPosition);
+ seriesSettingsLayout->addRow("Vertical position", m_vPosition);
+ seriesSettingsLayout->addRow("Size factor", m_sizeFactor);
+ seriesSettingsLayout->addRow("Start angle", m_startAngle);
+ seriesSettingsLayout->addRow("End angle", m_endAngle);
+ seriesSettingsLayout->addRow("Hole size", m_holeSize);
+ seriesSettingsLayout->addRow(appendSlice);
+ seriesSettingsLayout->addRow(insertSlice);
+ seriesSettingsLayout->addRow(removeSlice);
+ QGroupBox *seriesSettings = new QGroupBox("Series");
+ seriesSettings->setLayout(seriesSettingsLayout);
+
+ connect(m_vPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(m_hPosition, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(m_sizeFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(m_startAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(m_endAngle, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(m_holeSize, SIGNAL(valueChanged(double)), this, SLOT(updateSerieSettings()));
+ connect(appendSlice, SIGNAL(clicked()), this, SLOT(appendSlice()));
+ connect(insertSlice, SIGNAL(clicked()), this, SLOT(insertSlice()));
+ connect(removeSlice, SIGNAL(clicked()), this, SLOT(removeSlice()));
+
+ // slice settings
+ m_sliceName = new QLineEdit("<click a slice>");
+ m_sliceName->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ m_sliceValue = new QDoubleSpinBox();
+ m_sliceValue->setMaximum(1000);
+ m_sliceLabelVisible = new QCheckBox();
+ m_sliceLabelArmFactor = new QDoubleSpinBox();
+ m_sliceLabelArmFactor->setSingleStep(0.01);
+ m_sliceExploded = new QCheckBox();
+ m_sliceExplodedFactor = new QDoubleSpinBox();
+ m_sliceExplodedFactor->setSingleStep(0.01);
+ m_pen = new QPushButton();
+ m_penTool = new PenTool("Slice pen", this);
+ m_brush = new QPushButton();
+ m_brushTool = new BrushTool("Slice brush", this);
+ m_font = new QPushButton();
+ m_labelBrush = new QPushButton();
+ m_labelBrushTool = new BrushTool("Label brush", this);
+ m_labelPosition = new QComboBox(this);
+ m_labelPosition->addItem("Outside", QPieSlice::LabelOutside);
+ m_labelPosition->addItem("Inside horizontal", QPieSlice::LabelInsideHorizontal);
+ m_labelPosition->addItem("Inside tangential", QPieSlice::LabelInsideTangential);
+ m_labelPosition->addItem("Inside normal", QPieSlice::LabelInsideNormal);
+
+ QFormLayout *sliceSettingsLayout = new QFormLayout();
+ sliceSettingsLayout->addRow("Label", m_sliceName);
+ sliceSettingsLayout->addRow("Value", m_sliceValue);
+ sliceSettingsLayout->addRow("Pen", m_pen);
+ sliceSettingsLayout->addRow("Brush", m_brush);
+ sliceSettingsLayout->addRow("Label visible", m_sliceLabelVisible);
+ sliceSettingsLayout->addRow("Label font", m_font);
+ sliceSettingsLayout->addRow("Label brush", m_labelBrush);
+ sliceSettingsLayout->addRow("Label position", m_labelPosition);
+ sliceSettingsLayout->addRow("Label arm length", m_sliceLabelArmFactor);
+ sliceSettingsLayout->addRow("Exploded", m_sliceExploded);
+ sliceSettingsLayout->addRow("Explode distance", m_sliceExplodedFactor);
+ QGroupBox *sliceSettings = new QGroupBox("Selected slice");
+ sliceSettings->setLayout(sliceSettingsLayout);
+
+ connect(m_sliceName, SIGNAL(textChanged(QString)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceValue, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
+ connect(m_pen, SIGNAL(clicked()), m_penTool, SLOT(show()));
+ connect(m_penTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
+ connect(m_brush, SIGNAL(clicked()), m_brushTool, SLOT(show()));
+ connect(m_brushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
+ connect(m_font, SIGNAL(clicked()), this, SLOT(showFontDialog()));
+ connect(m_labelBrush, SIGNAL(clicked()), m_labelBrushTool, SLOT(show()));
+ connect(m_labelBrushTool, SIGNAL(changed()), this, SLOT(updateSliceSettings()));
+ connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceLabelVisible, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceLabelArmFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceExploded, SIGNAL(toggled(bool)), this, SLOT(updateSliceSettings()));
+ connect(m_sliceExplodedFactor, SIGNAL(valueChanged(double)), this, SLOT(updateSliceSettings()));
+ connect(m_labelPosition, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSliceSettings()));
+
+ // create chart view
+ m_chartView = new QChartView(chart);
+
+ // create main layout
+ QVBoxLayout *settingsLayout = new QVBoxLayout();
+ settingsLayout->addWidget(chartSettings);
+ settingsLayout->addWidget(seriesSettings);
+ settingsLayout->addWidget(sliceSettings);
+ settingsLayout->addStretch();
+
+ QGridLayout *baseLayout = new QGridLayout();
+ baseLayout->addLayout(settingsLayout, 0, 0);
+ baseLayout->addWidget(m_chartView, 0, 1);
+ setLayout(baseLayout);
+
+ updateSerieSettings();
+ updateChartSettings();
+}
+
+
+void MainWidget::updateChartSettings()
+{
+ QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt();
+ m_chartView->chart()->setTheme(theme);
+ m_chartView->setRenderHint(QPainter::Antialiasing, m_aaCheckBox->isChecked());
+
+ if (m_animationsCheckBox->checkState() == Qt::Checked)
+ m_chartView->chart()->setAnimationOptions(QChart::AllAnimations);
+ else
+ m_chartView->chart()->setAnimationOptions(QChart::NoAnimation);
+
+ if (m_legendCheckBox->checkState() == Qt::Checked)
+ m_chartView->chart()->legend()->show();
+ else
+ m_chartView->chart()->legend()->hide();
+}
+
+void MainWidget::updateSerieSettings()
+{
+ m_series->setHorizontalPosition(m_hPosition->value());
+ m_series->setVerticalPosition(m_vPosition->value());
+ m_series->setPieSize(m_sizeFactor->value());
+ m_holeSize->setMaximum(m_sizeFactor->value());
+ m_series->setPieStartAngle(m_startAngle->value());
+ m_series->setPieEndAngle(m_endAngle->value());
+ m_series->setHoleSize(m_holeSize->value());
+}
+
+void MainWidget::updateSliceSettings()
+{
+ if (!m_slice)
+ return;
+
+ m_slice->setLabel(m_sliceName->text());
+
+ m_slice->setValue(m_sliceValue->value());
+
+ m_slice->setPen(m_penTool->pen());
+ m_slice->setBrush(m_brushTool->brush());
+
+ m_slice->setLabelBrush(m_labelBrushTool->brush());
+ m_slice->setLabelVisible(m_sliceLabelVisible->isChecked());
+ m_slice->setLabelArmLengthFactor(m_sliceLabelArmFactor->value());
+ m_slice->setLabelPosition((QPieSlice::LabelPosition)m_labelPosition->currentIndex()); // assumes that index is in sync with the enum
+
+ m_slice->setExploded(m_sliceExploded->isChecked());
+ m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value());
+}
+
+void MainWidget::handleSliceClicked(QPieSlice *slice)
+{
+ m_slice = static_cast<CustomSlice *>(slice);
+
+ // name
+ m_sliceName->blockSignals(true);
+ m_sliceName->setText(slice->label());
+ m_sliceName->blockSignals(false);
+
+ // value
+ m_sliceValue->blockSignals(true);
+ m_sliceValue->setValue(slice->value());
+ m_sliceValue->blockSignals(false);
+
+ // pen
+ m_pen->setText(PenTool::name(m_slice->pen()));
+ m_penTool->setPen(m_slice->pen());
+
+ // brush
+ m_brush->setText(m_slice->originalBrush().color().name());
+ m_brushTool->setBrush(m_slice->originalBrush());
+
+ // label
+ m_labelBrush->setText(BrushTool::name(m_slice->labelBrush()));
+ m_labelBrushTool->setBrush(m_slice->labelBrush());
+ m_font->setText(slice->labelFont().toString());
+ m_sliceLabelVisible->blockSignals(true);
+ m_sliceLabelVisible->setChecked(slice->isLabelVisible());
+ m_sliceLabelVisible->blockSignals(false);
+ m_sliceLabelArmFactor->blockSignals(true);
+ m_sliceLabelArmFactor->setValue(slice->labelArmLengthFactor());
+ m_sliceLabelArmFactor->blockSignals(false);
+ m_labelPosition->blockSignals(true);
+ m_labelPosition->setCurrentIndex(slice->labelPosition()); // assumes that index is in sync with the enum
+ m_labelPosition->blockSignals(false);
+
+ // exploded
+ m_sliceExploded->blockSignals(true);
+ m_sliceExploded->setChecked(slice->isExploded());
+ m_sliceExploded->blockSignals(false);
+ m_sliceExplodedFactor->blockSignals(true);
+ m_sliceExplodedFactor->setValue(slice->explodeDistanceFactor());
+ m_sliceExplodedFactor->blockSignals(false);
+}
+
+void MainWidget::showFontDialog()
+{
+ if (!m_slice)
+ return;
+
+ QFontDialog dialog(m_slice->labelFont());
+ dialog.show();
+ dialog.exec();
+
+ m_slice->setLabelFont(dialog.currentFont());
+ m_font->setText(dialog.currentFont().toString());
+}
+
+void MainWidget::appendSlice()
+{
+ *m_series << new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0);
+}
+
+void MainWidget::insertSlice()
+{
+ if (!m_slice)
+ return;
+
+ int i = m_series->slices().indexOf(m_slice);
+
+ m_series->insert(i, new CustomSlice("Slice " + QString::number(m_series->count() + 1), 10.0));
+}
+
+void MainWidget::removeSlice()
+{
+ if (!m_slice)
+ return;
+
+ m_sliceName->setText("<click a slice>");
+
+ m_series->remove(m_slice);
+ m_slice = 0;
+}
+
+#include "moc_mainwidget.cpp"
diff --git a/examples/charts/piechartcustomization/mainwidget.h b/examples/charts/piechartcustomization/mainwidget.h
new file mode 100644
index 00000000..e9d3ada1
--- /dev/null
+++ b/examples/charts/piechartcustomization/mainwidget.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <QWidget>
+#include <QChartGlobal>
+
+class QLineEdit;
+class QPushButton;
+class QCheckBox;
+class QComboBox;
+class QDoubleSpinBox;
+class PenTool;
+class BrushTool;
+class CustomSlice;
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QChartView;
+class QPieSeries;
+class QPieSlice;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+class MainWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MainWidget(QWidget *parent = 0);
+
+public Q_SLOTS:
+ void updateChartSettings();
+ void updateSerieSettings();
+ void updateSliceSettings();
+ void handleSliceClicked(QPieSlice *slice);
+ void showFontDialog();
+ void appendSlice();
+ void insertSlice();
+ void removeSlice();
+
+private:
+ QComboBox *m_themeComboBox;
+ QCheckBox *m_aaCheckBox;
+ QCheckBox *m_animationsCheckBox;
+ QCheckBox *m_legendCheckBox;
+
+ QChartView *m_chartView;
+ QPieSeries *m_series;
+ CustomSlice *m_slice;
+
+ QDoubleSpinBox *m_hPosition;
+ QDoubleSpinBox *m_vPosition;
+ QDoubleSpinBox *m_sizeFactor;
+ QDoubleSpinBox *m_startAngle;
+ QDoubleSpinBox *m_endAngle;
+ QDoubleSpinBox *m_holeSize;
+
+ QLineEdit *m_sliceName;
+ QDoubleSpinBox *m_sliceValue;
+ QCheckBox *m_sliceLabelVisible;
+ QDoubleSpinBox *m_sliceLabelArmFactor;
+ QCheckBox *m_sliceExploded;
+ QDoubleSpinBox *m_sliceExplodedFactor;
+ QPushButton *m_brush;
+ BrushTool *m_brushTool;
+ QPushButton *m_pen;
+ PenTool *m_penTool;
+ QPushButton *m_font;
+ QPushButton *m_labelBrush;
+ QComboBox *m_labelPosition;
+ BrushTool *m_labelBrushTool;
+};
+
+#endif // MAINWIDGET_H
diff --git a/examples/charts/piechartcustomization/pentool.cpp b/examples/charts/piechartcustomization/pentool.cpp
new file mode 100644
index 00000000..104231ee
--- /dev/null
+++ b/examples/charts/piechartcustomization/pentool.cpp
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** 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 "pentool.h"
+#include <QPushButton>
+#include <QDoubleSpinBox>
+#include <QComboBox>
+#include <QFormLayout>
+#include <QColorDialog>
+
+PenTool::PenTool(QString title, QWidget *parent)
+ : QWidget(parent)
+{
+ setWindowTitle(title);
+ setWindowFlags(Qt::Tool);
+
+ m_colorButton = new QPushButton();
+
+ m_widthSpinBox = new QDoubleSpinBox();
+
+ m_styleCombo = new QComboBox();
+ m_styleCombo->addItem("NoPen");
+ m_styleCombo->addItem("SolidLine");
+ m_styleCombo->addItem("DashLine");
+ m_styleCombo->addItem("DotLine");
+ m_styleCombo->addItem("DashDotLine");
+ m_styleCombo->addItem("DashDotDotLine");
+
+ m_capStyleCombo = new QComboBox();
+ m_capStyleCombo->addItem("FlatCap", Qt::FlatCap);
+ m_capStyleCombo->addItem("SquareCap", Qt::SquareCap);
+ m_capStyleCombo->addItem("RoundCap", Qt::RoundCap);
+
+ m_joinStyleCombo = new QComboBox();
+ m_joinStyleCombo->addItem("MiterJoin", Qt::MiterJoin);
+ m_joinStyleCombo->addItem("BevelJoin", Qt::BevelJoin);
+ m_joinStyleCombo->addItem("RoundJoin", Qt::RoundJoin);
+ m_joinStyleCombo->addItem("SvgMiterJoin", Qt::SvgMiterJoin);
+
+ QFormLayout *layout = new QFormLayout();
+ layout->addRow("Color", m_colorButton);
+ layout->addRow("Width", m_widthSpinBox);
+ layout->addRow("Style", m_styleCombo);
+ layout->addRow("Cap style", m_capStyleCombo);
+ layout->addRow("Join style", m_joinStyleCombo);
+ setLayout(layout);
+
+ connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
+ connect(m_widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateWidth(double)));
+ connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle(int)));
+ connect(m_capStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCapStyle(int)));
+ connect(m_joinStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateJoinStyle(int)));
+}
+
+void PenTool::setPen(const QPen &pen)
+{
+ m_pen = pen;
+ m_colorButton->setText(m_pen.color().name());
+ m_widthSpinBox->setValue(m_pen.widthF());
+ m_styleCombo->setCurrentIndex(m_pen.style()); // index matches the enum
+ m_capStyleCombo->setCurrentIndex(m_capStyleCombo->findData(m_pen.capStyle()));
+ m_joinStyleCombo->setCurrentIndex(m_joinStyleCombo->findData(m_pen.joinStyle()));
+}
+
+QPen PenTool::pen() const
+{
+ return m_pen;
+}
+
+QString PenTool::name()
+{
+ return name(m_pen);
+}
+
+QString PenTool::name(const QPen &pen)
+{
+ return pen.color().name() + ":" + QString::number(pen.widthF());
+}
+
+void PenTool::showColorDialog()
+{
+ QColorDialog dialog(m_pen.color());
+ dialog.show();
+ dialog.exec();
+ m_pen.setColor(dialog.selectedColor());
+ m_colorButton->setText(m_pen.color().name());
+ emit changed();
+}
+
+void PenTool::updateWidth(double width)
+{
+ if (!qFuzzyCompare((qreal) width, m_pen.widthF())) {
+ m_pen.setWidthF(width);
+ emit changed();
+ }
+}
+
+void PenTool::updateStyle(int style)
+{
+ if (m_pen.style() != style) {
+ m_pen.setStyle((Qt::PenStyle) style);
+ emit changed();
+ }
+}
+
+void PenTool::updateCapStyle(int index)
+{
+ Qt::PenCapStyle capStyle = (Qt::PenCapStyle) m_capStyleCombo->itemData(index).toInt();
+ if (m_pen.capStyle() != capStyle) {
+ m_pen.setCapStyle(capStyle);
+ emit changed();
+ }
+}
+
+void PenTool::updateJoinStyle(int index)
+{
+ Qt::PenJoinStyle joinStyle = (Qt::PenJoinStyle) m_joinStyleCombo->itemData(index).toInt();
+ if (m_pen.joinStyle() != joinStyle) {
+ m_pen.setJoinStyle(joinStyle);
+ emit changed();
+ }
+}
+
+#include "moc_pentool.cpp"
diff --git a/examples/charts/piechartcustomization/pentool.h b/examples/charts/piechartcustomization/pentool.h
new file mode 100644
index 00000000..66e7ab10
--- /dev/null
+++ b/examples/charts/piechartcustomization/pentool.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 PENTOOL_H
+#define PENTOOL_H
+
+#include <QWidget>
+#include <QPen>
+
+class QPushButton;
+class QDoubleSpinBox;
+class QComboBox;
+
+class PenTool : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit PenTool(QString title, QWidget *parent = 0);
+ void setPen(const QPen &pen);
+ QPen pen() const;
+ QString name();
+ static QString name(const QPen &pen);
+
+Q_SIGNALS:
+ void changed();
+
+public Q_SLOTS:
+ void showColorDialog();
+ void updateWidth(double width);
+ void updateStyle(int style);
+ void updateCapStyle(int index);
+ void updateJoinStyle(int index);
+
+private:
+ QPen m_pen;
+ QPushButton *m_colorButton;
+ QDoubleSpinBox *m_widthSpinBox;
+ QComboBox *m_styleCombo;
+ QComboBox *m_capStyleCombo;
+ QComboBox *m_joinStyleCombo;
+};
+
+#endif // PENTOOL_H
diff --git a/examples/charts/piechartcustomization/piechartcustomization.pro b/examples/charts/piechartcustomization/piechartcustomization.pro
new file mode 100644
index 00000000..722744de
--- /dev/null
+++ b/examples/charts/piechartcustomization/piechartcustomization.pro
@@ -0,0 +1,16 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = piechartcustomization
+SOURCES += main.cpp \
+ pentool.cpp \
+ brushtool.cpp \
+ customslice.cpp \
+ mainwidget.cpp
+
+HEADERS += \
+ pentool.h \
+ brushtool.h \
+ customslice.h \
+ mainwidget.h
diff --git a/examples/charts/piechartdrilldown/drilldownchart.cpp b/examples/charts/piechartdrilldown/drilldownchart.cpp
new file mode 100644
index 00000000..b326472c
--- /dev/null
+++ b/examples/charts/piechartdrilldown/drilldownchart.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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 "drilldownchart.h"
+#include "drilldownslice.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QChart(QChart::ChartTypeCartesian, parent, wFlags),
+ m_currentSeries(0)
+{
+
+}
+
+DrilldownChart::~DrilldownChart()
+{
+
+}
+
+void DrilldownChart::changeSeries(QAbstractSeries *series)
+{
+ // NOTE: if the series is owned by the chart it will be deleted
+ // here the "window" owns the series...
+ if (m_currentSeries)
+ removeSeries(m_currentSeries);
+ m_currentSeries = series;
+ addSeries(series);
+ setTitle(series->name());
+}
+
+void DrilldownChart::handleSliceClicked(QPieSlice *slice)
+{
+ DrilldownSlice *drilldownSlice = static_cast<DrilldownSlice *>(slice);
+ changeSeries(drilldownSlice->drilldownSeries());
+}
+
+#include "moc_drilldownchart.cpp"
diff --git a/examples/charts/piechartdrilldown/drilldownchart.h b/examples/charts/piechartdrilldown/drilldownchart.h
new file mode 100644
index 00000000..554b6651
--- /dev/null
+++ b/examples/charts/piechartdrilldown/drilldownchart.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** 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 DRILLDOWNCHART_H
+#define DRILLDOWNCHART_H
+
+#include <QChart>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QAbstractSeries;
+class QPieSlice;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+class DrilldownChart : public QChart
+{
+ Q_OBJECT
+public:
+ explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ ~DrilldownChart();
+ void changeSeries(QAbstractSeries *series);
+
+public Q_SLOTS:
+ void handleSliceClicked(QPieSlice *slice);
+
+private:
+ QAbstractSeries *m_currentSeries;
+};
+
+#endif // DRILLDOWNCHART_H
diff --git a/examples/charts/piechartdrilldown/drilldownslice.cpp b/examples/charts/piechartdrilldown/drilldownslice.cpp
new file mode 100644
index 00000000..c04d7fe7
--- /dev/null
+++ b/examples/charts/piechartdrilldown/drilldownslice.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 "drilldownslice.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries)
+ : m_drilldownSeries(drilldownSeries),
+ m_prefix(prefix)
+{
+ setValue(value);
+ updateLabel();
+ setLabelFont(QFont("Arial", 8));
+ connect(this, SIGNAL(percentageChanged()), this, SLOT(updateLabel()));
+ connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool)));
+}
+
+DrilldownSlice::~DrilldownSlice()
+{
+
+}
+
+QAbstractSeries *DrilldownSlice::drilldownSeries() const
+{
+ return m_drilldownSeries;
+}
+
+void DrilldownSlice::updateLabel()
+{
+ QString label = m_prefix;
+ label += " $";
+ label += QString::number(this->value());
+ label += ", ";
+ label += QString::number(this->percentage() * 100, 'f', 1);
+ label += "%";
+ setLabel(label);
+}
+
+void DrilldownSlice::showHighlight(bool show)
+{
+ setLabelVisible(show);
+ setExploded(show);
+}
+
+#include "moc_drilldownslice.cpp"
diff --git a/examples/charts/piechartdrilldown/drilldownslice.h b/examples/charts/piechartdrilldown/drilldownslice.h
new file mode 100644
index 00000000..9743e852
--- /dev/null
+++ b/examples/charts/piechartdrilldown/drilldownslice.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 DRILLDOWNSLICE_H
+#define DRILLDOWNSLICE_H
+
+#include <QPieSlice>
+
+QT_CHARTS_BEGIN_NAMESPACE
+class QAbstractSeries;
+QT_CHARTS_END_NAMESPACE
+
+QT_CHARTS_USE_NAMESPACE
+
+class DrilldownSlice : public QPieSlice
+{
+ Q_OBJECT
+
+public:
+ DrilldownSlice(qreal value, QString prefix, QAbstractSeries *drilldownSeries);
+ virtual ~DrilldownSlice();
+ QAbstractSeries *drilldownSeries() const;
+
+public Q_SLOTS:
+ void updateLabel();
+ void showHighlight(bool show);
+
+private:
+ QAbstractSeries *m_drilldownSeries;
+ QString m_prefix;
+};
+
+#endif // DRILLDOWNSLICE_H
diff --git a/examples/charts/piechartdrilldown/main.cpp b/examples/charts/piechartdrilldown/main.cpp
new file mode 100644
index 00000000..a32587ff
--- /dev/null
+++ b/examples/charts/piechartdrilldown/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 "drilldownchart.h"
+#include "drilldownslice.h"
+#include <QApplication>
+#include <QMainWindow>
+#include <QTime>
+#include <QChartView>
+#include <QLegend>
+#include <QPieSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
+
+ QMainWindow window;
+
+ DrilldownChart *chart = new DrilldownChart();
+ chart->setTheme(QChart::ChartThemeLight);
+ chart->setAnimationOptions(QChart::AllAnimations);
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignRight);
+
+ QPieSeries *yearSeries = new QPieSeries(&window);
+ yearSeries->setName("Sales by year - All");
+
+ QList<QString> months;
+ months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
+ QList<QString> names;
+ names << "Jane" << "John" << "Axel" << "Mary" << "Susan" << "Bob";
+
+ foreach (QString name, names) {
+ QPieSeries *series = new QPieSeries(&window);
+ series->setName("Sales by month - " + name);
+
+ foreach (QString month, months)
+ *series << new DrilldownSlice(qrand() % 1000, month, yearSeries);
+
+ QObject::connect(series, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*)));
+
+ *yearSeries << new DrilldownSlice(series->sum(), name, series);
+ }
+
+ QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*)));
+
+ chart->changeSeries(yearSeries);
+
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ window.setCentralWidget(chartView);
+ window.resize(800, 500);
+ window.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/piechartdrilldown/piechartdrilldown.pro b/examples/charts/piechartdrilldown/piechartdrilldown.pro
new file mode 100644
index 00000000..0f9626c9
--- /dev/null
+++ b/examples/charts/piechartdrilldown/piechartdrilldown.pro
@@ -0,0 +1,11 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = piechartdrilldown
+SOURCES += main.cpp \
+ drilldownslice.cpp \
+ drilldownchart.cpp
+
+HEADERS += \
+ drilldownchart.h \
+ drilldownslice.h
diff --git a/examples/charts/polarchart/chartview.cpp b/examples/charts/polarchart/chartview.cpp
new file mode 100644
index 00000000..038ce709
--- /dev/null
+++ b/examples/charts/polarchart/chartview.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <QMouseEvent>
+#include <QDebug>
+#include <QAbstractAxis>
+#include <QValueAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+ChartView::ChartView(QWidget *parent)
+ : QChartView(parent)
+{
+}
+
+//![1]
+void ChartView::keyPressEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_Plus:
+ chart()->zoomIn();
+ break;
+ case Qt::Key_Minus:
+ chart()->zoomOut();
+ break;
+ case Qt::Key_Left:
+ chart()->scroll(-1.0, 0);
+ break;
+ case Qt::Key_Right:
+ chart()->scroll(1.0, 0);
+ break;
+ case Qt::Key_Up:
+ chart()->scroll(0, 1.0);
+ break;
+ case Qt::Key_Down:
+ chart()->scroll(0, -1.0);
+ break;
+ case Qt::Key_Space:
+ switchChartType();
+ break;
+ default:
+ QGraphicsView::keyPressEvent(event);
+ break;
+ }
+}
+//![1]
+
+//![2]
+void ChartView::switchChartType()
+{
+ QChart *newChart;
+ QChart *oldChart = chart();
+
+ if (oldChart->chartType() == QChart::ChartTypeCartesian)
+ newChart = new QPolarChart();
+ else
+ newChart = new QChart();
+
+ // Move series and axes from old chart to new one
+ QList<QAbstractSeries *> seriesList = oldChart->series();
+ QList<QAbstractAxis *> axisList = oldChart->axes();
+ QList<QPair<qreal, qreal> > axisRanges;
+
+ foreach (QAbstractAxis *axis, axisList) {
+ QValueAxis *valueAxis = static_cast<QValueAxis *>(axis);
+ axisRanges.append(QPair<qreal, qreal>(valueAxis->min(), valueAxis->max()));
+ }
+
+ foreach (QAbstractSeries *series, seriesList)
+ oldChart->removeSeries(series);
+
+ foreach (QAbstractAxis *axis, axisList) {
+ oldChart->removeAxis(axis);
+ newChart->addAxis(axis, axis->alignment());
+ }
+
+ foreach (QAbstractSeries *series, seriesList) {
+ newChart->addSeries(series);
+ foreach (QAbstractAxis *axis, axisList)
+ series->attachAxis(axis);
+ }
+
+ int count = 0;
+ foreach (QAbstractAxis *axis, axisList) {
+ axis->setRange(axisRanges[count].first, axisRanges[count].second);
+ count++;
+ }
+
+ newChart->setTitle(oldChart->title());
+ setChart(newChart);
+ delete oldChart;
+}
+//![2]
diff --git a/examples/charts/polarchart/chartview.h b/examples/charts/polarchart/chartview.h
new file mode 100644
index 00000000..9f59b469
--- /dev/null
+++ b/examples/charts/polarchart/chartview.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** 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 CHARTVIEW_H
+#define CHARTVIEW_H
+
+#include <QChartView>
+#include <QPolarChart>
+
+QT_CHARTS_USE_NAMESPACE
+
+class ChartView : public QChartView
+{
+public:
+ ChartView(QWidget *parent = 0);
+
+protected:
+ void keyPressEvent(QKeyEvent *event);
+
+private:
+ void switchChartType();
+};
+
+#endif
diff --git a/examples/charts/polarchart/main.cpp b/examples/charts/polarchart/main.cpp
new file mode 100644
index 00000000..cc959519
--- /dev/null
+++ b/examples/charts/polarchart/main.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <QApplication>
+#include <QMainWindow>
+#include <QScatterSeries>
+#include <QLineSeries>
+#include <QSplineSeries>
+#include <QAreaSeries>
+#include <QValueAxis>
+#include <QPolarChart>
+#include <QDebug>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ const qreal angularMin = -100;
+ const qreal angularMax = 100;
+
+ const qreal radialMin = -100;
+ const qreal radialMax = 100;
+
+ QScatterSeries *series1 = new QScatterSeries();
+ series1->setName("scatter");
+ for (int i = angularMin; i <= angularMax; i += 10)
+ series1->append(i, (i / radialMax) * radialMax + 8.0);
+
+ QSplineSeries *series2 = new QSplineSeries();
+ series2->setName("spline");
+ for (int i = angularMin; i <= angularMax; i += 10)
+ series2->append(i, (i / radialMax) * radialMax);
+
+ QLineSeries *series3 = new QLineSeries();
+ series3->setName("star outer");
+ qreal ad = (angularMax - angularMin) / 8;
+ qreal rd = (radialMax - radialMin) / 3 * 1.3;
+ series3->append(angularMin, radialMax);
+ series3->append(angularMin + ad*1, radialMin + rd);
+ series3->append(angularMin + ad*2, radialMax);
+ series3->append(angularMin + ad*3, radialMin + rd);
+ series3->append(angularMin + ad*4, radialMax);
+ series3->append(angularMin + ad*5, radialMin + rd);
+ series3->append(angularMin + ad*6, radialMax);
+ series3->append(angularMin + ad*7, radialMin + rd);
+ series3->append(angularMin + ad*8, radialMax);
+
+ QLineSeries *series4 = new QLineSeries();
+ series4->setName("star inner");
+ ad = (angularMax - angularMin) / 8;
+ rd = (radialMax - radialMin) / 3;
+ series4->append(angularMin, radialMax);
+ series4->append(angularMin + ad*1, radialMin + rd);
+ series4->append(angularMin + ad*2, radialMax);
+ series4->append(angularMin + ad*3, radialMin + rd);
+ series4->append(angularMin + ad*4, radialMax);
+ series4->append(angularMin + ad*5, radialMin + rd);
+ series4->append(angularMin + ad*6, radialMax);
+ series4->append(angularMin + ad*7, radialMin + rd);
+ series4->append(angularMin + ad*8, radialMax);
+
+ QAreaSeries *series5 = new QAreaSeries();
+ series5->setName("star area");
+ series5->setUpperSeries(series3);
+ series5->setLowerSeries(series4);
+ series5->setOpacity(0.5);
+
+ //![1]
+ QPolarChart *chart = new QPolarChart();
+ //![1]
+ chart->addSeries(series1);
+ chart->addSeries(series2);
+ chart->addSeries(series3);
+ chart->addSeries(series4);
+ chart->addSeries(series5);
+
+ chart->setTitle("Use arrow keys to scroll, +/- to zoom, and space to switch chart type.");
+
+ //![2]
+ QValueAxis *angularAxis = new QValueAxis();
+ angularAxis->setTickCount(9); // First and last ticks are co-located on 0/360 angle.
+ angularAxis->setLabelFormat("%.1f");
+ angularAxis->setShadesVisible(true);
+ angularAxis->setShadesBrush(QBrush(QColor(249, 249, 255)));
+ chart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular);
+
+ QValueAxis *radialAxis = new QValueAxis();
+ radialAxis->setTickCount(9);
+ radialAxis->setLabelFormat("%d");
+ chart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial);
+ //![2]
+
+ series1->attachAxis(radialAxis);
+ series1->attachAxis(angularAxis);
+ series2->attachAxis(radialAxis);
+ series2->attachAxis(angularAxis);
+ series3->attachAxis(radialAxis);
+ series3->attachAxis(angularAxis);
+ series4->attachAxis(radialAxis);
+ series4->attachAxis(angularAxis);
+ series5->attachAxis(radialAxis);
+ series5->attachAxis(angularAxis);
+
+ radialAxis->setRange(radialMin, radialMax);
+ angularAxis->setRange(angularMin, angularMax);
+
+ ChartView *chartView = new ChartView();
+ chartView->setChart(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(800, 600);
+ window.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/polarchart/polarchart.pro b/examples/charts/polarchart/polarchart.pro
new file mode 100644
index 00000000..8759c1ce
--- /dev/null
+++ b/examples/charts/polarchart/polarchart.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = polarchart
+SOURCES += main.cpp chartview.cpp
+HEADERS += chartview.h
diff --git a/examples/charts/qmlaxes/main.cpp b/examples/charts/qmlaxes/main.cpp
new file mode 100644
index 00000000..bb0957e8
--- /dev/null
+++ b/examples/charts/qmlaxes/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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 <QtCore/QDir>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Axes"));
+ viewer.setSource(QUrl("qrc:/qml/qmlaxes/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View1.qml b/examples/charts/qmlaxes/qml/qmlaxes/View1.qml
new file mode 100644
index 00000000..4c09e269
--- /dev/null
+++ b/examples/charts/qmlaxes/qml/qmlaxes/View1.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Two Series, Common Axes"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ ValueAxis {
+ id: axisX
+ min: 0
+ max: 10
+ tickCount: 5
+ }
+
+ ValueAxis {
+ id: axisY
+ min: -0.5
+ max: 1.5
+ }
+
+ LineSeries {
+ id: series1
+ axisX: axisX
+ axisY: axisY
+ }
+
+ ScatterSeries {
+ id: series2
+ axisX: axisX
+ axisY: axisY
+ }
+ }
+
+ // Add data dynamically to the series
+ Component.onCompleted: {
+ for (var i = 0; i <= 10; i++) {
+ series1.append(i, Math.random());
+ series2.append(i, Math.random());
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View2.qml b/examples/charts/qmlaxes/qml/qmlaxes/View2.qml
new file mode 100644
index 00000000..4672c19f
--- /dev/null
+++ b/examples/charts/qmlaxes/qml/qmlaxes/View2.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Accurate Historical Data"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ LineSeries {
+ axisX: DateTimeAxis {
+ format: "yyyy MMM"
+ tickCount: 5
+ }
+ axisY: ValueAxis {
+ min: 0
+ max: 150
+ }
+
+ // Please note that month in JavaScript months are zero based, so 2 means March
+ XYPoint { x: toMsecsSinceEpoch(new Date(1950, 2, 15)); y: 5 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1987, 12, 31)); y: 102 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 2)); y: 110 }
+ }
+ }
+
+ // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to
+ // milliseconds since epoch to make them match the DateTimeAxis values
+ function toMsecsSinceEpoch(date) {
+ var msecs = date.getTime();
+ return msecs;
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlaxes/qml/qmlaxes/View3.qml b/examples/charts/qmlaxes/qml/qmlaxes/View3.qml
new file mode 100644
index 00000000..711833c6
--- /dev/null
+++ b/examples/charts/qmlaxes/qml/qmlaxes/View3.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Numerical Data for Dummies"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ LineSeries {
+ axisY: CategoryAxis {
+ min: 0
+ max: 30
+ CategoryRange {
+ label: "critical"
+ endValue: 2
+ }
+ CategoryRange {
+ label: "low"
+ endValue: 4
+ }
+ CategoryRange {
+ label: "normal"
+ endValue: 7
+ }
+ CategoryRange {
+ label: "high"
+ endValue: 15
+ }
+ CategoryRange {
+ label: "extremely high"
+ endValue: 30
+ }
+ }
+
+ XYPoint { x: 0; y: 4.3 }
+ XYPoint { x: 1; y: 4.1 }
+ XYPoint { x: 2; y: 4.7 }
+ XYPoint { x: 3; y: 3.9 }
+ XYPoint { x: 4; y: 5.2 }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlaxes/qml/qmlaxes/main.qml b/examples/charts/qmlaxes/qml/qmlaxes/main.qml
new file mode 100644
index 00000000..cc75dca3
--- /dev/null
+++ b/examples/charts/qmlaxes/qml/qmlaxes/main.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 440
+ height: 330
+ property bool sourceLoaded: false
+
+ ListView {
+ id: root
+ focus: true
+ anchors.fill: parent
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightMoveDuration: 250
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+
+ onCurrentIndexChanged: {
+ if (infoText.opacity > 0.0) {
+ if (sourceLoaded)
+ infoText.opacity = 0.0;
+ else if (currentIndex != 0)
+ currentIndex = 0;
+ }
+ }
+
+ model: ListModel {
+ ListElement {component: "View1.qml"}
+ ListElement {component: "View2.qml"}
+ ListElement {component: "View3.qml"}
+ }
+
+ delegate: Loader {
+ width: root.width
+ height: root.height
+
+ source: component
+ asynchronous: true
+
+ onLoaded: sourceLoaded = true
+ }
+ }
+
+ Rectangle {
+ id: infoText
+ anchors.centerIn: parent
+ width: parent.width
+ height: 40
+ color: "black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: "You can navigate between views using swipe or arrow keys"
+ }
+
+ Behavior on opacity {
+ NumberAnimation { duration: 400 }
+ }
+ }
+}
diff --git a/examples/charts/qmlaxes/qmlaxes.pro b/examples/charts/qmlaxes/qmlaxes.pro
new file mode 100644
index 00000000..50b4c012
--- /dev/null
+++ b/examples/charts/qmlaxes/qmlaxes.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlaxes/*
diff --git a/examples/charts/qmlaxes/resources.qrc b/examples/charts/qmlaxes/resources.qrc
new file mode 100644
index 00000000..c30b2f2c
--- /dev/null
+++ b/examples/charts/qmlaxes/resources.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlaxes/main.qml</file>
+ <file>qml/qmlaxes/View1.qml</file>
+ <file>qml/qmlaxes/View2.qml</file>
+ <file>qml/qmlaxes/View3.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlboxplot/main.cpp b/examples/charts/qmlboxplot/main.cpp
new file mode 100644
index 00000000..709bd5d2
--- /dev/null
+++ b/examples/charts/qmlboxplot/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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 <QDir>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Box Plot"));
+ viewer.setSource(QUrl("qrc:/qml/qmlboxplot/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml b/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml
new file mode 100644
index 00000000..bb71b5df
--- /dev/null
+++ b/examples/charts/qmlboxplot/qml/qmlboxplot/main.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+ChartView {
+ title: "Box Plot series"
+ width: 400
+ height: 300
+ theme: ChartView.ChartThemeBrownSand
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ BoxPlotSeries {
+ id: plotSeries
+ name: "Income"
+ BoxSet { label: "Jan"; values: [3, 4, 5.1, 6.2, 8.5] }
+ BoxSet { label: "Feb"; values: [5, 6, 7.5, 8.6, 11.8] }
+ BoxSet { label: "Mar"; values: [3.2, 5, 5.7, 8, 9.2] }
+ BoxSet { label: "Apr"; values: [3.8, 5, 6.4, 7, 8] }
+ BoxSet { label: "May"; values: [4, 5, 5.2, 6, 7] }
+ }
+}
diff --git a/examples/charts/qmlboxplot/qmlboxplot.pro b/examples/charts/qmlboxplot/qmlboxplot.pro
new file mode 100644
index 00000000..237f05f1
--- /dev/null
+++ b/examples/charts/qmlboxplot/qmlboxplot.pro
@@ -0,0 +1,9 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+
+OTHER_FILES += \
+ qml/qmlboxplot/main.qml
diff --git a/examples/charts/qmlboxplot/resources.qrc b/examples/charts/qmlboxplot/resources.qrc
new file mode 100644
index 00000000..49a98f16
--- /dev/null
+++ b/examples/charts/qmlboxplot/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlboxplot/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlchart/main.cpp b/examples/charts/qmlchart/main.cpp
new file mode 100644
index 00000000..16327b97
--- /dev/null
+++ b/examples/charts/qmlchart/main.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Chart"));
+
+ viewer.setSource(QUrl("qrc:/qml/qmlchart/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View1.qml b/examples/charts/qmlchart/qml/qmlchart/View1.qml
new file mode 100644
index 00000000..20590780
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View1.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//![2]
+import QtQuick 2.0
+//![2]
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+ property variant othersSlice: 0
+
+ //![1]
+ ChartView {
+ id: chart
+ title: "Top-5 car brand shares in Finland"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ PieSeries {
+ id: pieSeries
+ PieSlice { label: "Volkswagen"; value: 13.5 }
+ PieSlice { label: "Toyota"; value: 10.9 }
+ PieSlice { label: "Ford"; value: 8.6 }
+ PieSlice { label: "Skoda"; value: 8.2 }
+ PieSlice { label: "Volvo"; value: 6.8 }
+ }
+ }
+
+ Component.onCompleted: {
+ // You can also manipulate slices dynamically
+ othersSlice = pieSeries.append("Others", 52.0);
+ pieSeries.find("Volkswagen").exploded = true;
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View10.qml b/examples/charts/qmlchart/qml/qmlchart/View10.qml
new file mode 100644
index 00000000..a3e3442b
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View10.qml
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Horizontal Stacked Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ HorizontalStackedBarSeries {
+ axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View11.qml b/examples/charts/qmlchart/qml/qmlchart/View11.qml
new file mode 100644
index 00000000..68aaf907
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View11.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Horizontal Percent Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ HorizontalPercentBarSeries {
+ axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
+
diff --git a/examples/charts/qmlchart/qml/qmlchart/View12.qml b/examples/charts/qmlchart/qml/qmlchart/View12.qml
new file mode 100644
index 00000000..04be8f00
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View12.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ id: chart
+ title: "Production costs"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ PieSeries {
+ id: pieOuter
+ size: 0.96
+ holeSize: 0.7
+ PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#8AB846"; borderColor: "#163430" }
+ PieSlice { label: "Epsilon"; value: 11105; color: "#C0EEFF"; borderColor: "#3B391C" }
+ PieSlice { label: "Psi"; value: 9352; color: "#DF8939"; borderColor: "#13060C" }
+ }
+
+ PieSeries {
+ size: 0.7
+ id: pieInner
+ holeSize: 0.25
+
+ PieSlice { label: "Materials"; value: 10334; color: "#8AB846"; borderColor: "#163430" }
+ PieSlice { label: "Employee"; value: 3066; color: "#AAE356"; borderColor: "#163430" }
+ PieSlice { label: "Logistics"; value: 6111; color: "#99CC4E"; borderColor: "#163430" }
+
+ PieSlice { label: "Materials"; value: 7371; color: "#C0EEFF"; borderColor: "#3B391C" }
+ PieSlice { label: "Employee"; value: 2443; color: "#C9FAFF"; borderColor: "#3B391C" }
+ PieSlice { label: "Logistics"; value: 1291; color: "#B0FAFF"; borderColor: "#3B391C" }
+
+ PieSlice { label: "Materials"; value: 4022; color: "#DF8939"; borderColor: "#13060C" }
+ PieSlice { label: "Employee"; value: 3998; color: "#FC9D42"; borderColor: "#13060C" }
+ PieSlice { label: "Logistics"; value: 1332; color: "#F2963F"; borderColor: "#13060C" }
+ }
+ }
+
+ Component.onCompleted: {
+ // Set the common slice properties dynamically for convenience
+ for (var i = 0; i < pieOuter.count; i++) {
+ pieOuter.at(i).labelPosition = PieSlice.LabelOutside;
+ pieOuter.at(i).labelVisible = true;
+ pieOuter.at(i).borderWidth = 3;
+ }
+ for (var i = 0; i < pieInner.count; i++) {
+ pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal;
+ pieInner.at(i).labelVisible = true;
+ pieInner.at(i).borderWidth = 2;
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View2.qml b/examples/charts/qmlchart/qml/qmlchart/View2.qml
new file mode 100644
index 00000000..be0ae18d
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View2.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Line"
+ anchors.fill: parent
+ antialiasing: true
+
+ LineSeries {
+ name: "LineSeries"
+ XYPoint { x: 0; y: 0 }
+ XYPoint { x: 1.1; y: 2.1 }
+ XYPoint { x: 1.9; y: 3.3 }
+ XYPoint { x: 2.1; y: 2.1 }
+ XYPoint { x: 2.9; y: 4.9 }
+ XYPoint { x: 3.4; y: 3.0 }
+ XYPoint { x: 4.1; y: 3.3 }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View3.qml b/examples/charts/qmlchart/qml/qmlchart/View3.qml
new file mode 100644
index 00000000..e7680bea
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View3.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Spline"
+ anchors.fill: parent
+ antialiasing: true
+
+ SplineSeries {
+ name: "SplineSeries"
+ XYPoint { x: 0; y: 0.0 }
+ XYPoint { x: 1.1; y: 3.2 }
+ XYPoint { x: 1.9; y: 2.4 }
+ XYPoint { x: 2.1; y: 2.1 }
+ XYPoint { x: 2.9; y: 2.6 }
+ XYPoint { x: 3.4; y: 2.3 }
+ XYPoint { x: 4.1; y: 3.1 }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View4.qml b/examples/charts/qmlchart/qml/qmlchart/View4.qml
new file mode 100644
index 00000000..5ba5dc15
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View4.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "NHL All-Star Team Players"
+ anchors.fill: parent
+ antialiasing: true
+
+ ValueAxis {
+ id: valueAxis
+ min: 2000
+ max: 2011
+ tickCount: 12
+ labelFormat: "%.0f"
+ }
+
+ AreaSeries {
+ name: "Russian"
+ color: "#FFD52B1E"
+ borderColor: "#FF0039A5"
+ borderWidth: 3
+ axisX: valueAxis
+ upperSeries: LineSeries {
+ XYPoint { x: 2000; y: 1 }
+ XYPoint { x: 2001; y: 1 }
+ XYPoint { x: 2002; y: 1 }
+ XYPoint { x: 2003; y: 1 }
+ XYPoint { x: 2004; y: 1 }
+ XYPoint { x: 2005; y: 0 }
+ XYPoint { x: 2006; y: 1 }
+ XYPoint { x: 2007; y: 1 }
+ XYPoint { x: 2008; y: 4 }
+ XYPoint { x: 2009; y: 3 }
+ XYPoint { x: 2010; y: 2 }
+ XYPoint { x: 2011; y: 1 }
+ }
+ }
+ //![1]
+
+ AreaSeries {
+ name: "Swedish"
+ color: "#AF005292"
+ borderColor: "#AFFDCA00"
+ borderWidth: 3
+ axisX: valueAxis
+ upperSeries: LineSeries {
+ XYPoint { x: 2000; y: 1 }
+ XYPoint { x: 2001; y: 1 }
+ XYPoint { x: 2002; y: 3 }
+ XYPoint { x: 2003; y: 3 }
+ XYPoint { x: 2004; y: 2 }
+ XYPoint { x: 2005; y: 0 }
+ XYPoint { x: 2006; y: 2 }
+ XYPoint { x: 2007; y: 1 }
+ XYPoint { x: 2008; y: 2 }
+ XYPoint { x: 2009; y: 1 }
+ XYPoint { x: 2010; y: 3 }
+ XYPoint { x: 2011; y: 3 }
+ }
+ }
+
+ AreaSeries {
+ name: "Finnish"
+ color: "#00357F"
+ borderColor: "#FEFEFE"
+ borderWidth: 3
+ axisX: valueAxis
+ upperSeries: LineSeries {
+ XYPoint { x: 2000; y: 0 }
+ XYPoint { x: 2001; y: 0 }
+ XYPoint { x: 2002; y: 0 }
+ XYPoint { x: 2003; y: 0 }
+ XYPoint { x: 2004; y: 0 }
+ XYPoint { x: 2005; y: 0 }
+ XYPoint { x: 2006; y: 1 }
+ XYPoint { x: 2007; y: 0 }
+ XYPoint { x: 2008; y: 0 }
+ XYPoint { x: 2009; y: 0 }
+ XYPoint { x: 2010; y: 0 }
+ XYPoint { x: 2011; y: 1 }
+ }
+ }
+ }
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View5.qml b/examples/charts/qmlchart/qml/qmlchart/View5.qml
new file mode 100644
index 00000000..7cce1d77
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View5.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Scatters"
+ anchors.fill: parent
+ antialiasing: true
+
+ ScatterSeries {
+ id: scatter1
+ name: "Scatter1"
+ XYPoint { x: 1.5; y: 1.5 }
+ XYPoint { x: 1.5; y: 1.6 }
+ XYPoint { x: 1.57; y: 1.55 }
+ XYPoint { x: 1.8; y: 1.8 }
+ XYPoint { x: 1.9; y: 1.6 }
+ XYPoint { x: 2.1; y: 1.3 }
+ XYPoint { x: 2.5; y: 2.1 }
+ }
+
+ ScatterSeries {
+ name: "Scatter2"
+ //![1]
+ XYPoint { x: 2.0; y: 2.0 }
+ XYPoint { x: 2.0; y: 2.1 }
+ XYPoint { x: 2.07; y: 2.05 }
+ XYPoint { x: 2.2; y: 2.9 }
+ XYPoint { x: 2.4; y: 2.7 }
+ XYPoint { x: 2.67; y: 2.65 }
+ }
+ }
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View6.qml b/examples/charts/qmlchart/qml/qmlchart/View6.qml
new file mode 100644
index 00000000..78d3a834
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View6.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ BarSeries {
+ id: mySeries
+ axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View7.qml b/examples/charts/qmlchart/qml/qmlchart/View7.qml
new file mode 100644
index 00000000..4980e70b
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View7.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Stacked Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ StackedBarSeries {
+ id: mySeries
+ axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View8.qml b/examples/charts/qmlchart/qml/qmlchart/View8.qml
new file mode 100644
index 00000000..bba51cc9
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View8.qml
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Percent Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ PercentBarSeries {
+ axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlchart/qml/qmlchart/View9.qml b/examples/charts/qmlchart/qml/qmlchart/View9.qml
new file mode 100644
index 00000000..fe0f0a55
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/View9.qml
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ ChartView {
+ title: "Horizontal Bar series"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignBottom
+ antialiasing: true
+
+ HorizontalBarSeries {
+ axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
+ BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
+ BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
+ BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
+ }
+ }
+ //![1]
+}
+
diff --git a/examples/charts/qmlchart/qml/qmlchart/main.qml b/examples/charts/qmlchart/qml/qmlchart/main.qml
new file mode 100644
index 00000000..0a384636
--- /dev/null
+++ b/examples/charts/qmlchart/qml/qmlchart/main.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//![1]
+import QtQuick 2.0
+//![1]
+
+Rectangle {
+ width: 600
+ height: 400
+ property bool sourceLoaded: false
+
+ ListView {
+ id: root
+ focus: true
+ anchors.fill: parent
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightMoveDuration: 250
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+
+ onCurrentIndexChanged: {
+ if (infoText.opacity > 0.0) {
+ if (sourceLoaded)
+ infoText.opacity = 0.0;
+ else if (currentIndex != 0)
+ currentIndex = 0;
+ }
+ }
+
+ model: ListModel {
+ ListElement {component: "View1.qml"}
+ ListElement {component: "View2.qml"}
+ ListElement {component: "View3.qml"}
+ ListElement {component: "View4.qml"}
+ ListElement {component: "View5.qml"}
+ ListElement {component: "View6.qml"}
+ ListElement {component: "View7.qml"}
+ ListElement {component: "View8.qml"}
+ ListElement {component: "View9.qml"}
+ ListElement {component: "View10.qml"}
+ ListElement {component: "View11.qml"}
+ ListElement {component: "View12.qml"}
+ }
+
+ delegate: Loader {
+ width: root.width
+ height: root.height
+
+ source: component
+ asynchronous: true
+
+ onLoaded: sourceLoaded = true
+ }
+ }
+
+ Rectangle {
+ id: infoText
+ anchors.centerIn: parent
+ width: parent.width
+ height: 40
+ color: "black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: "You can navigate between views using swipe or arrow keys"
+ }
+
+ Behavior on opacity {
+ NumberAnimation { duration: 400 }
+ }
+ }
+}
diff --git a/examples/charts/qmlchart/qmlchart.pro b/examples/charts/qmlchart/qmlchart.pro
new file mode 100644
index 00000000..82426424
--- /dev/null
+++ b/examples/charts/qmlchart/qmlchart.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlchart/*
diff --git a/examples/charts/qmlchart/resources.qrc b/examples/charts/qmlchart/resources.qrc
new file mode 100644
index 00000000..7b14dace
--- /dev/null
+++ b/examples/charts/qmlchart/resources.qrc
@@ -0,0 +1,17 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlchart/main.qml</file>
+ <file>qml/qmlchart/View1.qml</file>
+ <file>qml/qmlchart/View2.qml</file>
+ <file>qml/qmlchart/View3.qml</file>
+ <file>qml/qmlchart/View4.qml</file>
+ <file>qml/qmlchart/View5.qml</file>
+ <file>qml/qmlchart/View6.qml</file>
+ <file>qml/qmlchart/View7.qml</file>
+ <file>qml/qmlchart/View8.qml</file>
+ <file>qml/qmlchart/View9.qml</file>
+ <file>qml/qmlchart/View10.qml</file>
+ <file>qml/qmlchart/View11.qml</file>
+ <file>qml/qmlchart/View12.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlcustomizations/main.cpp b/examples/charts/qmlcustomizations/main.cpp
new file mode 100644
index 00000000..e36fd058
--- /dev/null
+++ b/examples/charts/qmlcustomizations/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Customizations"));
+ viewer.setSource(QUrl("qrc:/qml/qmlcustomizations/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml b/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml
new file mode 100644
index 00000000..8000caf7
--- /dev/null
+++ b/examples/charts/qmlcustomizations/qml/qmlcustomizations/main.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ width: 400
+ height: 300
+ property int __activeIndex: 1
+ property real __intervalCoefficient: 0
+
+ //![1]
+ ChartView {
+ id: chartView
+ anchors.fill: parent
+ title: "Wheel of fortune"
+ legend.visible: false
+ antialiasing: true
+
+ PieSeries {
+ id: wheelOfFortune
+ horizontalPosition: 0.3
+ }
+
+ SplineSeries {
+ id: splineSeries
+ }
+
+ ScatterSeries {
+ id: scatterSeries
+ }
+ }
+ //![1]
+
+ //![2]
+ Component.onCompleted: {
+ __intervalCoefficient = Math.random() + 0.1;
+
+ for (var i = 0; i < 20; i++)
+ wheelOfFortune.append("", 1);
+
+ var interval = 1;
+ for (var j = 0; interval < 800; j++) {
+ interval = __intervalCoefficient * j * j;
+ splineSeries.append(j, interval);
+ }
+ chartView.axisX(scatterSeries).max = j;
+ chartView.axisY(scatterSeries).max = 1000;
+ }
+ //![2]
+
+ Timer {
+ triggeredOnStart: true
+ running: true
+ repeat: true
+ interval: 100
+ onTriggered: {
+ var index = __activeIndex % wheelOfFortune.count;
+ if (interval < 700) {
+ //![3]
+ wheelOfFortune.at(index).exploded = false;
+ __activeIndex++;
+ index = __activeIndex % wheelOfFortune.count;
+ wheelOfFortune.at(index).exploded = true;
+ //![3]
+ interval = splineSeries.at(__activeIndex).y;
+ //![4]
+ scatterSeries.clear();
+ scatterSeries.append(__activeIndex, interval);
+ scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000");
+ scatterSeries.markerSize += 0.5;
+ //![4]
+ } else {
+ //![5]
+ // Switch the colors of the slice and the border
+ wheelOfFortune.at(index).borderWidth = 2;
+ var borderColor = wheelOfFortune.at(index).borderColor;
+ wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color;
+ wheelOfFortune.at(index).color = borderColor;
+ //![5]
+ }
+ }
+ }
+}
diff --git a/examples/charts/qmlcustomizations/qmlcustomizations.pro b/examples/charts/qmlcustomizations/qmlcustomizations.pro
new file mode 100644
index 00000000..ae2d4e5b
--- /dev/null
+++ b/examples/charts/qmlcustomizations/qmlcustomizations.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlcustomizations/*
diff --git a/examples/charts/qmlcustomizations/resources.qrc b/examples/charts/qmlcustomizations/resources.qrc
new file mode 100644
index 00000000..35dd1b54
--- /dev/null
+++ b/examples/charts/qmlcustomizations/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlcustomizations/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlcustomlegend/main.cpp b/examples/charts/qmlcustomlegend/main.cpp
new file mode 100644
index 00000000..82cda036
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Custom Legend"));
+ viewer.setSource(QUrl("qrc:/qml/qmlcustomlegend/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml
new file mode 100644
index 00000000..0af6b5c3
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+AreaSeries {
+ id: series
+
+ Behavior on opacity {
+ NumberAnimation { duration: 250 }
+ }
+}
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml
new file mode 100644
index 00000000..7ca033b2
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+//![1]
+ChartView {
+ id: chartViewHighlighted
+ title: ""
+ property variant selectedSeries
+ signal clicked
+ legend.visible: false
+ margins.top: 10
+ margins.bottom: 0
+ antialiasing: true
+
+ LineSeries {
+ id: lineSeries
+
+ axisX: ValueAxis {
+ min: 2006
+ max: 2012
+ labelFormat: "%.0f"
+ tickCount: 7
+ }
+ axisY: ValueAxis {
+ id: axisY
+ titleText: "EUR"
+ min: 0
+ max: 40000
+ niceNumbersEnabled: true
+ labelFormat: "%.0f"
+ tickCount: 5
+ }
+ }
+//![1]
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ chartViewHighlighted.clicked();
+ }
+ }
+
+ onSelectedSeriesChanged: {
+ lineSeries.clear();
+ lineSeries.color = selectedSeries.color;
+ var maxVal = 0.0;
+ for (var i = 0; i < selectedSeries.upperSeries.count; i++ ) {
+ var y = selectedSeries.upperSeries.at(i).y - selectedSeries.lowerSeries.at(i).y;
+ lineSeries.append(selectedSeries.upperSeries.at(i).x, y);
+ if (maxVal < y)
+ maxVal = y;
+ }
+ chartViewHighlighted.title = selectedSeries.name;
+ axisY.max = maxVal;
+ }
+}
+
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml
new file mode 100644
index 00000000..86714a01
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ id: chartViewSelector
+ width: parent.width
+ height: parent.height
+ signal seriesAdded(string seriesName, color seriesColor)
+
+ function highlightSeries(seriesName) {
+ if (seriesName == "") {
+ if (state != "")
+ state = "";
+
+ for (var i = 0; i < chartViewStacked.count; i++)
+ chartViewStacked.series(i).opacity = 1.0;
+ } else {
+ var targetOpacity = 0.1;
+ for (var j = 0; j < chartViewStacked.count; j++) {
+ if (chartViewStacked.series(j).name != seriesName)
+ chartViewStacked.series(j).opacity = 0.25;
+ else if (state == "highlight")
+ chartViewSelected.selectedSeries = chartViewStacked.series(j);
+ }
+ }
+ }
+
+ function selectSeries(seriesName) {
+ for (var i = 0; i < chartViewStacked.count; i++) {
+ if (chartViewStacked.series(i).name == seriesName) {
+ chartViewSelected.selectedSeries = chartViewStacked.series(i);
+ if (chartViewSelector.state == "")
+ chartViewSelector.state = "highlighted";
+ else
+ chartViewSelector.state = "";
+ }
+ }
+ }
+
+ ChartViewStacked {
+ id: chartViewStacked
+ anchors.left: parent.left
+ anchors.leftMargin: 0
+ width: parent.width
+ height: parent.height
+ onSeriesAdded: chartViewSelector.seriesAdded(series.name, series.color);
+ }
+
+ ChartViewHighlighted {
+ id: chartViewSelected
+ anchors.left: chartViewStacked.right
+ width: parent.width
+ height: parent.height
+
+ opacity: 0.0
+ onClicked: {
+ chartViewSelector.state = "";
+ }
+ }
+
+ states: State {
+ name: "highlighted"
+ PropertyChanges {
+ target: chartViewSelected
+ opacity: 1.0
+ }
+ PropertyChanges {
+ target: chartViewStacked
+ anchors.leftMargin: -chartViewStacked.width
+ opacity: 0.0
+ }
+ }
+
+ transitions: Transition {
+ PropertyAnimation {
+ properties: "width, height, opacity, anchors.leftMargin"
+ duration: 400
+ }
+ }
+}
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml
new file mode 100644
index 00000000..ade88c04
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+ChartView {
+ id: chartView
+ title: "Government Taxes"
+ legend.visible: false
+ signal entered(string seriesName)
+ signal exited(string seriesName)
+ margins.top: 10
+ margins.bottom: 0
+ antialiasing: true
+
+ ValueAxis {
+ id: axisX
+ min: 2006
+ max: 2012
+ tickCount: 7
+ labelFormat: "%.0f"
+ }
+
+ ValueAxis {
+ id: axisY
+ titleText: "EUR"
+ min: 0
+ max: 90000
+ tickCount: 10
+ labelFormat: "%.0f"
+ }
+
+ AnimatedAreaSeries {
+ id: stateSeries
+ name: "state"
+ axisX: axisX
+ axisY: axisY
+ borderWidth: 0
+ upperSeries: LineSeries {
+ id: stateUpper
+ XYPoint { x: 2006; y: 33119 }
+ XYPoint { x: 2007; y: 37941 }
+ XYPoint { x: 2008; y: 40122 }
+ XYPoint { x: 2009; y: 38991 }
+ XYPoint { x: 2010; y: 34055 }
+ XYPoint { x: 2011; y: 34555 }
+ XYPoint { x: 2012; y: 38991 }
+ }
+ lowerSeries: LineSeries {
+ XYPoint { x: 2006; y: 0 }
+ XYPoint { x: 2007; y: 0 }
+ XYPoint { x: 2008; y: 0 }
+ XYPoint { x: 2009; y: 0 }
+ XYPoint { x: 2010; y: 0 }
+ XYPoint { x: 2011; y: 0 }
+ XYPoint { x: 2012; y: 0 }
+ }
+ }
+
+ //![1]
+ AnimatedAreaSeries {
+ id: municipalSeries
+ name: "municipal"
+ axisX: axisX
+ axisY: axisY
+ borderWidth: 0
+ upperSeries: LineSeries {
+ id: municipalUpper
+ XYPoint { x: 2006; y: 33119 + 13443 }
+ XYPoint { x: 2007; y: 37941 + 15311 }
+ XYPoint { x: 2008; y: 40122 + 16552 }
+ XYPoint { x: 2009; y: 38991 + 17904 }
+ XYPoint { x: 2010; y: 34055 + 17599 }
+ XYPoint { x: 2011; y: 34555 + 19002 }
+ XYPoint { x: 2012; y: 38991 + 19177 }
+ }
+ lowerSeries: stateUpper
+ }
+ //![1]
+
+ AnimatedAreaSeries {
+ id: socialSeries
+ name: "social sec."
+ axisX: axisX
+ axisY: axisY
+ borderWidth: 0
+ upperSeries: LineSeries {
+ id: socialUpper
+ XYPoint { x: 2006; y: 33119 + 13443 + 18855 }
+ XYPoint { x: 2007; y: 37941 + 15311 + 20238 }
+ XYPoint { x: 2008; y: 40122 + 16552 + 21347 }
+ XYPoint { x: 2009; y: 38991 + 17904 + 22376 }
+ XYPoint { x: 2010; y: 34055 + 17599 + 22076 }
+ XYPoint { x: 2011; y: 34555 + 19002 + 22631 }
+ XYPoint { x: 2012; y: 38991 + 19177 + 23686 }
+ }
+ lowerSeries: municipalUpper
+ }
+}
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml
new file mode 100644
index 00000000..d146f83c
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ id: legend
+ color: "lightgray"
+
+ property int seriesCount: 0
+ property variant seriesNames: []
+ property variant seriesColors: []
+ signal entered(string seriesName)
+ signal exited(string seriesName)
+ signal selected(string seriesName)
+
+ function addSeries(seriesName, color) {
+ var names = seriesNames;
+ names[seriesCount] = seriesName;
+ seriesNames = names;
+
+ var colors = seriesColors;
+ colors[seriesCount] = color;
+ seriesColors = colors;
+
+ seriesCount++;
+ }
+
+ Gradient {
+ id: buttonGradient
+ GradientStop { position: 0.0; color: "#F0F0F0" }
+ GradientStop { position: 1.0; color: "#A0A0A0" }
+ }
+
+ Gradient {
+ id: buttonGradientHovered
+ GradientStop { position: 0.0; color: "#FFFFFF" }
+ GradientStop { position: 1.0; color: "#B0B0B0" }
+ }
+
+ //![2]
+ Component {
+ id: legendDelegate
+ Rectangle {
+ id: rect
+ //![2]
+ property string name: seriesNames[index]
+ property color markerColor: seriesColors[index]
+ gradient: buttonGradient
+ border.color: "#A0A0A0"
+ border.width: 1
+ radius: 4
+
+ implicitWidth: label.implicitWidth + marker.implicitWidth + 30
+ implicitHeight: label.implicitHeight + marker.implicitHeight + 10
+
+ Row {
+ id: row
+ spacing: 5
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 5
+ Rectangle {
+ id: marker
+ anchors.verticalCenter: parent.verticalCenter
+ color: markerColor
+ opacity: 0.3
+ radius: 4
+ width: 12
+ height: 10
+ }
+ Text {
+ id: label
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: -1
+ text: name
+ }
+ }
+
+ //![3]
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onEntered: {
+ rect.gradient = buttonGradientHovered;
+ legend.entered(label.text);
+ }
+ onExited: {
+ rect.gradient = buttonGradient;
+ legend.exited(label.text);
+ marker.opacity = 0.3;
+ marker.height = 10;
+ }
+ onClicked: {
+ legend.selected(label.text);
+ marker.opacity = 1.0;
+ marker.height = 12;
+ }
+ }
+ //![3]
+ }
+ }
+
+ //![1]
+ Row {
+ id: legendRow
+ anchors.centerIn: parent
+ spacing: 10
+
+ Repeater {
+ id: legendRepeater
+ model: seriesCount
+ delegate: legendDelegate
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml
new file mode 100644
index 00000000..815d5331
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qml/qmlcustomlegend/main.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ id: main
+ width: 400
+ height: 320
+
+ Column {
+ id: column
+ anchors.fill: parent
+ anchors.bottomMargin: 10
+ spacing: 0
+
+ ChartViewSelector {
+ id: chartViewSelector
+ width: parent.width
+ height: parent.height - customLegend.height - anchors.bottomMargin
+ onSeriesAdded: customLegend.addSeries(seriesName, seriesColor);
+ }
+
+ CustomLegend {
+ id: customLegend
+ width: parent.width
+ height: 50
+ anchors.horizontalCenter: parent.horizontalCenter
+ onEntered: chartViewSelector.highlightSeries(seriesName);
+ onExited: chartViewSelector.highlightSeries("");
+ onSelected: chartViewSelector.selectSeries(seriesName);
+ }
+ }
+
+ states: State {
+ name: "highlighted"
+ PropertyChanges {
+ target: chartViewHighlighted
+ width: column.width
+ height: (column.height - column.anchors.margins * 2 - customLegend.height)
+ }
+ PropertyChanges {
+ target: chartViewStacked
+ width: 1
+ height: 1
+ }
+ }
+}
diff --git a/examples/charts/qmlcustomlegend/qmlcustomlegend.pro b/examples/charts/qmlcustomlegend/qmlcustomlegend.pro
new file mode 100644
index 00000000..d42afded
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/qmlcustomlegend.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlcustomlegend/*
diff --git a/examples/charts/qmlcustomlegend/resources.qrc b/examples/charts/qmlcustomlegend/resources.qrc
new file mode 100644
index 00000000..bd49690b
--- /dev/null
+++ b/examples/charts/qmlcustomlegend/resources.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlcustomlegend/main.qml</file>
+ <file>qml/qmlcustomlegend/CustomLegend.qml</file>
+ <file>qml/qmlcustomlegend/ChartViewStacked.qml</file>
+ <file>qml/qmlcustomlegend/ChartViewHighlighted.qml</file>
+ <file>qml/qmlcustomlegend/ChartViewSelector.qml</file>
+ <file>qml/qmlcustomlegend/AnimatedAreaSeries.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlf1legends/main.cpp b/examples/charts/qmlf1legends/main.cpp
new file mode 100644
index 00000000..df79b769
--- /dev/null
+++ b/examples/charts/qmlf1legends/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML F1 Legends"));
+ viewer.setSource(QUrl("qrc:/qml/qmlf1legends/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml b/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml
new file mode 100644
index 00000000..00d45a17
--- /dev/null
+++ b/examples/charts/qmlf1legends/qml/qmlf1legends/SpeedsXml.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick.XmlListModel 2.0
+
+//![1]
+XmlListModel {
+ // Hard-coded test data
+ xml: "<results><row><speedTrap>0</speedTrap><driver>Fittipaldi</driver><speed>104.12</speed></row>"
+ +"<row><speedTrap>0</speedTrap><driver>Stewart</driver><speed>106.12</speed></row>"
+ +"<row><speedTrap>0</speedTrap><driver>Hunt</driver><speed>106.12</speed></row>"
+//![1]
+ +"<row><speedTrap>1</speedTrap><driver>Fittipaldi</driver><speed>115.12</speed></row>"
+ +"<row><speedTrap>1</speedTrap><driver>Stewart</driver><speed>114.12</speed></row>"
+ +"<row><speedTrap>1</speedTrap><driver>Hunt</driver><speed>115.12</speed></row>"
+ +"<row><speedTrap>2</speedTrap><driver>Hunt</driver><speed>165.23</speed></row>"
+ +"<row><speedTrap>2</speedTrap><driver>Fittipaldi</driver><speed>175.23</speed></row>"
+ +"<row><speedTrap>2</speedTrap><driver>Stewart</driver><speed>168.23</speed></row>"
+ +"<row><speedTrap>3</speedTrap><driver>Hunt</driver><speed>104.87</speed></row>"
+ +"<row><speedTrap>3</speedTrap><driver>Fittipaldi</driver><speed>104.43</speed></row>"
+ +"<row><speedTrap>3</speedTrap><driver>Stewart</driver><speed>94.83</speed></row>"
+ +"<row><speedTrap>4</speedTrap><driver>Hunt</driver><speed>107.87</speed></row>"
+ +"<row><speedTrap>4</speedTrap><driver>Fittipaldi</driver><speed>111.84</speed></row>"
+ +"<row><speedTrap>4</speedTrap><driver>Stewart</driver><speed>106.84</speed></row>"
+ +"<row><speedTrap>5</speedTrap><driver>Hunt</driver><speed>94.87</speed></row>"
+ +"<row><speedTrap>5</speedTrap><driver>Stewart</driver><speed>92.37</speed></row>"
+ +"<row><speedTrap>5</speedTrap><driver>Fittipaldi</driver><speed>99.37</speed></row>"
+ +"<row><speedTrap>6</speedTrap><driver>Hunt</driver><speed>52.87</speed></row>"
+ +"<row><speedTrap>6</speedTrap><driver>Fittipaldi</driver><speed>42.87</speed></row>"
+ +"<row><speedTrap>6</speedTrap><driver>Stewart</driver><speed>55.87</speed></row>"
+ +"<row><speedTrap>7</speedTrap><driver>Hunt</driver><speed>77.87</speed></row>"
+ +"<row><speedTrap>7</speedTrap><driver>Fittipaldi</driver><speed>72.87</speed></row>"
+ +"<row><speedTrap>7</speedTrap><driver>Stewart</driver><speed>87.87</speed></row>"
+ +"<row><speedTrap>8</speedTrap><driver>Hunt</driver><speed>94.17</speed></row>"
+ +"<row><speedTrap>8</speedTrap><driver>Fittipaldi</driver><speed>98.17</speed></row>"
+ +"<row><speedTrap>8</speedTrap><driver>Stewart</driver><speed>84.17</speed></row>"
+ +"<row><speedTrap>9</speedTrap><driver>Hunt</driver><speed>91.87</speed></row>"
+ +"<row><speedTrap>9</speedTrap><driver>Fittipaldi</driver><speed>71.87</speed></row>"
+ +"<row><speedTrap>9</speedTrap><driver>Stewart</driver><speed>81.87</speed></row>"
+ +"<row><speedTrap>10</speedTrap><driver>Hunt</driver><speed>104.87</speed></row>"
+ +"<row><speedTrap>10</speedTrap><driver>Fittipaldi</driver><speed>115.87</speed></row>"
+ +"<row><speedTrap>10</speedTrap><driver>Stewart</driver><speed>119.87</speed></row>"
+ +"<row><speedTrap>11</speedTrap><driver>Hunt</driver><speed>162.87</speed></row>"
+ +"<row><speedTrap>11</speedTrap><driver>Fittipaldi</driver><speed>155.84</speed></row>"
+ +"<row><speedTrap>11</speedTrap><driver>Stewart</driver><speed>152.84</speed></row>"
+ +"<row><speedTrap>12</speedTrap><driver>Hunt</driver><speed>181.87</speed></row>"
+ +"<row><speedTrap>12</speedTrap><driver>Fittipaldi</driver><speed>161.85</speed></row>"
+ +"<row><speedTrap>12</speedTrap><driver>Stewart</driver><speed>167.85</speed></row>"
+ +"<row><speedTrap>13</speedTrap><driver>Hunt</driver><speed>155.87</speed></row>"
+ +"<row><speedTrap>13</speedTrap><driver>Fittipaldi</driver><speed>154.87</speed></row>"
+ +"<row><speedTrap>13</speedTrap><driver>Stewart</driver><speed>164.87</speed></row>"
+ +"<row><speedTrap>14</speedTrap><driver>Hunt</driver><speed>197.57</speed></row>"
+ +"<row><speedTrap>14</speedTrap><driver>Fittipaldi</driver><speed>187.54</speed></row>"
+ +"<row><speedTrap>14</speedTrap><driver>Stewart</driver><speed>180.54</speed></row>"
+ +"<row><speedTrap>15</speedTrap><driver>Fittipaldi</driver><speed>216.87</speed></row>"
+ +"<row><speedTrap>15</speedTrap><driver>Hunt</driver><speed>207.87</speed></row>"
+ +"<row><speedTrap>15</speedTrap><driver>Stewart</driver><speed>197.87</speed></row>"
+ +"<row><speedTrap>16</speedTrap><driver>Hunt</driver><speed>82.87</speed></row>"
+ +"<row><speedTrap>16</speedTrap><driver>Fittipaldi</driver><speed>79.37</speed></row>"
+ +"<row><speedTrap>16</speedTrap><driver>Stewart</driver><speed>85.37</speed></row>"
+ +"<row><speedTrap>17</speedTrap><driver>Hunt</driver><speed>153.87</speed></row>"
+ +"<row><speedTrap>17</speedTrap><driver>Fittipaldi</driver><speed>143.87</speed></row>"
+ +"<row><speedTrap>17</speedTrap><driver>Stewart</driver><speed>133.87</speed></row>"
+ +"<row><speedTrap>18</speedTrap><driver>Hunt</driver><speed>89.87</speed></row>"
+ +"<row><speedTrap>18</speedTrap><driver>Fittipaldi</driver><speed>95.85</speed></row>"
+ +"<row><speedTrap>18</speedTrap><driver>Stewart</driver><speed>98.85</speed></row>"
+ +"<row><speedTrap>19</speedTrap><driver>Hunt</driver><speed>169.87</speed></row>"
+ +"<row><speedTrap>19</speedTrap><driver>Stewart</driver><speed>167.87</speed></row>"
+ +"<row><speedTrap>19</speedTrap><driver>Fittipaldi</driver><speed>154.87</speed></row>"
+ +"</results>"
+//![2]
+ query: "/results/row"
+
+ XmlRole { name: "speedTrap"; query: "speedTrap/string()" }
+ XmlRole { name: "driver"; query: "driver/string()" }
+ XmlRole { name: "speed"; query: "speed/string()" }
+}
+//![2]
diff --git a/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml b/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml
new file mode 100644
index 00000000..9aaec276
--- /dev/null
+++ b/examples/charts/qmlf1legends/qml/qmlf1legends/main.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+import QtQuick.XmlListModel 2.0
+
+Rectangle {
+ width: 400
+ height: 300
+ property int currentIndex: -1
+
+ //![1]
+ ChartView {
+ id: chartView
+ title: "Driver Speeds, lap 1"
+ anchors.fill: parent
+ legend.alignment: Qt.AlignTop
+ animationOptions: ChartView.SeriesAnimations
+ antialiasing: true
+ }
+ //![1]
+
+ //![2]
+ // An example XmlListModel containing F1 legend drivers' speeds at speed traps
+ SpeedsXml {
+ id: speedsXml
+ onStatusChanged: {
+ if (status == XmlListModel.Ready) {
+ timer.start();
+ }
+ }
+ }
+ //![2]
+
+ //![3]
+ // A timer to mimic refreshing the data dynamically
+ Timer {
+ id: timer
+ interval: 700
+ repeat: true
+ triggeredOnStart: true
+ running: false
+ onTriggered: {
+ currentIndex++;
+ if (currentIndex < speedsXml.count) {
+ // Check if there is a series for the data already (we are using driver name to identify series)
+ var lineSeries = chartView.series(speedsXml.get(currentIndex).driver);
+ if (!lineSeries) {
+ lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver);
+ chartView.axisY().min = 0;
+ chartView.axisY().max = 250;
+ chartView.axisY().tickCount = 6;
+ chartView.axisY().titleText = "speed (kph)";
+ chartView.axisX().titleText = "speed trap";
+ chartView.axisX().labelFormat = "%.0f";
+ }
+ lineSeries.append(speedsXml.get(currentIndex).speedTrap, speedsXml.get(currentIndex).speed);
+
+ if (speedsXml.get(currentIndex).speedTrap > 3) {
+ chartView.axisX().max = Number(speedsXml.get(currentIndex).speedTrap) + 1;
+ chartView.axisX().min = chartView.axisX().max - 5;
+ } else {
+ chartView.axisX().max = 5;
+ chartView.axisX().min = 0;
+ }
+ chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1;
+ } else {
+ // No more data, change x-axis range to show all the data
+ timer.stop();
+ chartView.animationOptions = ChartView.AllAnimations;
+ chartView.axisX().min = 0;
+ chartView.axisX().max = speedsXml.get(currentIndex - 1).speedTrap;
+ }
+ }
+ }
+ //![3]
+}
diff --git a/examples/charts/qmlf1legends/qmlf1legends.pro b/examples/charts/qmlf1legends/qmlf1legends.pro
new file mode 100644
index 00000000..fc8c04f4
--- /dev/null
+++ b/examples/charts/qmlf1legends/qmlf1legends.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlf1legends/*
diff --git a/examples/charts/qmlf1legends/resources.qrc b/examples/charts/qmlf1legends/resources.qrc
new file mode 100644
index 00000000..2a89c915
--- /dev/null
+++ b/examples/charts/qmlf1legends/resources.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlf1legends/main.qml</file>
+ <file>qml/qmlf1legends/SpeedsXml.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmloscilloscope/datasource.cpp b/examples/charts/qmloscilloscope/datasource.cpp
new file mode 100644
index 00000000..ff651110
--- /dev/null
+++ b/examples/charts/qmloscilloscope/datasource.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** 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 "datasource.h"
+#include <QXYSeries>
+#include <QAreaSeries>
+#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickItem>
+#include <QDebug>
+#include <qmath.h>
+
+QT_CHARTS_USE_NAMESPACE
+
+Q_DECLARE_METATYPE(QAbstractSeries *)
+Q_DECLARE_METATYPE(QAbstractAxis *)
+
+DataSource::DataSource(QQuickView *appViewer, QObject *parent) :
+ QObject(parent),
+ m_appViewer(appViewer),
+ m_index(-1)
+{
+ qRegisterMetaType<QAbstractSeries*>();
+ qRegisterMetaType<QAbstractAxis*>();
+
+ generateData(0, 5, 1024);
+}
+
+void DataSource::update(QAbstractSeries *series)
+{
+ if (series) {
+ QXYSeries *xySeries = static_cast<QXYSeries *>(series);
+ m_index++;
+ if (m_index > m_data.count() - 1)
+ m_index = 0;
+
+ QList<QPointF> points = m_data.at(m_index);
+ // Use replace instead of clear + append, it's optimized for performance
+ xySeries->replace(points);
+ }
+}
+
+void DataSource::generateData(int type, int rowCount, int colCount)
+{
+ // Remove previous data
+ foreach (QList<QPointF> row, m_data)
+ row.clear();
+ m_data.clear();
+
+ // Append the new data depending on the type
+ for (int i(0); i < rowCount; i++) {
+ QList<QPointF> points;
+ for (int j(0); j < colCount; j++) {
+ qreal x(0);
+ qreal y(0);
+ switch (type) {
+ case 0:
+ // data with sin + random component
+ y = qSin(3.14159265358979 / 50 * j) + 0.5 + (qreal) rand() / (qreal) RAND_MAX;
+ x = j;
+ break;
+ case 1:
+ // linear data
+ x = j;
+ y = (qreal) i / 10;
+ break;
+ default:
+ // unknown, do nothing
+ break;
+ }
+ points.append(QPointF(x, y));
+ }
+ m_data.append(points);
+ }
+}
diff --git a/examples/charts/qmloscilloscope/datasource.h b/examples/charts/qmloscilloscope/datasource.h
new file mode 100644
index 00000000..8cb8daa7
--- /dev/null
+++ b/examples/charts/qmloscilloscope/datasource.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 DATASOURCE_H
+#define DATASOURCE_H
+
+#include <QObject>
+#include <QAbstractSeries>
+
+class QQuickView;
+
+QT_CHARTS_USE_NAMESPACE
+
+class DataSource : public QObject
+{
+ Q_OBJECT
+public:
+ explicit DataSource(QQuickView *appViewer, QObject *parent = 0);
+
+signals:
+
+public slots:
+ void generateData(int type, int rowCount, int colCount);
+ void update(QAbstractSeries *series);
+
+private:
+ QQuickView *m_appViewer;
+ QList<QList<QPointF> > m_data;
+ int m_index;
+};
+
+#endif // DATASOURCE_H
diff --git a/examples/charts/qmloscilloscope/main.cpp b/examples/charts/qmloscilloscope/main.cpp
new file mode 100644
index 00000000..cb68260f
--- /dev/null
+++ b/examples/charts/qmloscilloscope/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQml/QQmlContext>
+#include <QtQuick/QQuickView>
+#include <QtQml/QQmlEngine>
+#include <QtCore/QDir>
+#include "datasource.h"
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Oscilloscope"));
+
+ DataSource dataSource(&viewer);
+ viewer.rootContext()->setContextProperty("dataSource", &dataSource);
+
+ viewer.setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml
new file mode 100644
index 00000000..72b9b5df
--- /dev/null
+++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+
+ColumnLayout {
+ spacing: 8
+ Layout.fillHeight: true
+ signal animationsEnabled(bool enabled)
+ signal seriesTypeChanged(string type)
+ signal refreshRateChanged(variant rate);
+ signal signalSourceChanged(string source, int signalCount, int sampleCount);
+ signal antialiasingEnabled(bool enabled)
+
+ Text {
+ text: "Scope"
+ font.pointSize: 18
+ color: "white"
+ }
+
+ MultiButton {
+ text: "Graph: "
+ items: ["line", "spline", "scatter"]
+ currentSelection: 0
+ onSelectionChanged: seriesTypeChanged(items[currentSelection]);
+ }
+
+ MultiButton {
+ id: signalSourceButton
+ text: "Source: "
+ items: ["sin", "linear"]
+ currentSelection: 0
+ onSelectionChanged: signalSourceChanged(
+ selection,
+ 5,
+ sampleCountButton.items[sampleCountButton.currentSelection]);
+ }
+
+ MultiButton {
+ id: sampleCountButton
+ text: "Samples: "
+ items: [6, 128, 1024, 10000]
+ currentSelection: 2
+ onSelectionChanged: signalSourceChanged(
+ signalSourceButton.items[signalSourceButton.currentSelection],
+ 5,
+ selection);
+ }
+
+ MultiButton {
+ text: "Refresh rate: "
+ items: [1, 24, 60, 100]
+ currentSelection: 2
+ onSelectionChanged: refreshRateChanged(items[currentSelection]);
+ }
+
+ MultiButton {
+ text: "Animations: "
+ items: ["OFF", "ON"]
+ currentSelection: 0
+ onSelectionChanged: animationsEnabled(currentSelection == 1);
+ }
+
+ MultiButton {
+ text: "Antialias: "
+ items: ["OFF", "ON"]
+ currentSelection: 0
+ onSelectionChanged: antialiasingEnabled(currentSelection == 1);
+ }
+}
diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml
new file mode 100644
index 00000000..8f6e1e1e
--- /dev/null
+++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ id: button
+
+ property string text: "Option: "
+ property variant items: ["first"]
+ property int currentSelection: 0
+ signal selectionChanged(variant selection)
+
+ signal clicked
+
+ implicitWidth: buttonText.implicitWidth + 5
+ implicitHeight: buttonText.implicitHeight + 10
+
+ Button {
+ id: buttonText
+ width: parent.width
+ height: parent.height
+
+ style: ButtonStyle {
+ label: Component {
+ Text {
+ text: button.text + button.items[currentSelection]
+ clip: true
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ }
+ }
+ }
+ onClicked: {
+ currentSelection = (currentSelection + 1) % items.length;
+ selectionChanged(button.items[currentSelection]);
+ }
+ }
+}
diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml
new file mode 100644
index 00000000..d27bf0aa
--- /dev/null
+++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/ScopeView.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+//![1]
+ChartView {
+ id: chartView
+ animationOptions: ChartView.NoAnimation
+ theme: ChartView.ChartThemeDark
+
+ ValueAxis {
+ id: axisY1
+ min: -1
+ max: 4
+ }
+
+ ValueAxis {
+ id: axisY2
+ min: -10
+ max: 5
+ }
+
+ ValueAxis {
+ id: axisX
+ min: 0
+ max: 1000
+ }
+
+ LineSeries {
+ id: lineSeries1
+ name: "signal 1"
+ axisX: axisX
+ axisY: axisY1
+ }
+ LineSeries {
+ id: lineSeries2
+ name: "signal 2"
+ axisX: axisX
+ axisYRight: axisY2
+ }
+//![1]
+
+ //![2]
+ Timer {
+ id: refreshTimer
+ interval: 1 / 60 * 1000 // 60 Hz
+ running: true
+ repeat: true
+ onTriggered: {
+ dataSource.update(chartView.series(0));
+ dataSource.update(chartView.series(1));
+ }
+ }
+ //![2]
+
+ //![3]
+ function changeSeriesType(type) {
+ chartView.removeAllSeries();
+
+ // Create two new series of the correct type. Axis x is the same for both of the series,
+ // but the series have their own y-axes to make it possible to control the y-offset
+ // of the "signal sources".
+ if (type == "line") {
+ chartView.createSeries(ChartView.SeriesTypeLine, "signal 1", axisX, axisY1);
+ chartView.createSeries(ChartView.SeriesTypeLine, "signal 2", axisX, axisY2);
+ } else if (type == "spline") {
+ chartView.createSeries(ChartView.SeriesTypeSpline, "signal 1", axisX, axisY1);
+ chartView.createSeries(ChartView.SeriesTypeSpline, "signal 2", axisX, axisY2);
+ } else {
+ var series1 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 1", axisX, axisY1);
+ series1.markerSize = 3;
+ series1.borderColor = "transparent";
+ var series2 = chartView.createSeries(ChartView.SeriesTypeScatter, "signal 2", axisX, axisY2);
+ series2.markerSize = 3;
+ series2.borderColor = "transparent";
+ }
+ }
+
+ function createAxis(min, max) {
+ // The following creates a ValueAxis object that can be then set as a x or y axis for a series
+ return Qt.createQmlObject("import QtQuick 2.0; import QtCharts 2.0; ValueAxis { min: "
+ + min + "; max: " + max + " }", chartView);
+ }
+ //![3]
+
+ function setAnimations(enabled) {
+ if (enabled)
+ chartView.animationOptions = ChartView.SeriesAnimations;
+ else
+ chartView.animationOptions = ChartView.NoAnimation;
+ }
+
+ function changeRefreshRate(rate) {
+ refreshTimer.interval = 1 / Number(rate) * 1000;
+ }
+}
diff --git a/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml b/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml
new file mode 100644
index 00000000..c88dfab3
--- /dev/null
+++ b/examples/charts/qmloscilloscope/qml/qmloscilloscope/main.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+//![1]
+Rectangle {
+ id: main
+ width: 400
+ height: 300
+ color: "#404040"
+
+ ControlPanel {
+ id: controlPanel
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+//![1]
+
+ onSignalSourceChanged: {
+ if (source == "sin")
+ dataSource.generateData(0, signalCount, sampleCount);
+ else
+ dataSource.generateData(1, signalCount, sampleCount);
+ }
+ onAnimationsEnabled: scopeView.setAnimations(enabled);
+ onSeriesTypeChanged: scopeView.changeSeriesType(type);
+ onRefreshRateChanged: scopeView.changeRefreshRate(rate);
+ onAntialiasingEnabled: scopeView.antialiasing = enabled;
+ }
+
+//![2]
+ ScopeView {
+ id: scopeView
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ anchors.left: controlPanel.right
+ height: main.height
+ }
+//![2]
+}
diff --git a/examples/charts/qmloscilloscope/qmloscilloscope.pro b/examples/charts/qmloscilloscope/qmloscilloscope.pro
new file mode 100644
index 00000000..a66fabcd
--- /dev/null
+++ b/examples/charts/qmloscilloscope/qmloscilloscope.pro
@@ -0,0 +1,11 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp \
+ datasource.cpp
+OTHER_FILES += qml/qmloscilloscope/*
+
+HEADERS += \
+ datasource.h
diff --git a/examples/charts/qmloscilloscope/resources.qrc b/examples/charts/qmloscilloscope/resources.qrc
new file mode 100644
index 00000000..e2aadae8
--- /dev/null
+++ b/examples/charts/qmloscilloscope/resources.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmloscilloscope/main.qml</file>
+ <file>qml/qmloscilloscope/ControlPanel.qml</file>
+ <file>qml/qmloscilloscope/ScopeView.qml</file>
+ <file>qml/qmloscilloscope/MultiButton.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlpiechart/main.cpp b/examples/charts/qmlpiechart/main.cpp
new file mode 100644
index 00000000..5162b540
--- /dev/null
+++ b/examples/charts/qmlpiechart/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Pie Chart"));
+ viewer.setSource(QUrl("qrc:/qml/qmlpiechart/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml b/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml
new file mode 100644
index 00000000..b836539b
--- /dev/null
+++ b/examples/charts/qmlpiechart/qml/qmlpiechart/main.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+//![1]
+import QtQuick 2.0
+import QtCharts 2.0
+
+ChartView {
+ width: 400
+ height: 300
+ theme: ChartView.ChartThemeBrownSand
+ antialiasing: true
+
+//![1]
+//![2]
+ PieSeries {
+ id: pieSeries
+ PieSlice { label: "eaten"; value: 94.9 }
+ PieSlice { label: "not yet eaten"; value: 5.1 }
+ }
+//![2]
+
+ Component.onCompleted: {
+ if (false) {
+ //![4]
+ pieSeries.append("don't care", 1.1);
+ //![4]
+
+ //![5]
+ pieSeries.at(0).exploded = true;
+ //![5]
+ }
+ }
+
+//![3]
+}
+//![3]
diff --git a/examples/charts/qmlpiechart/qmlpiechart.pro b/examples/charts/qmlpiechart/qmlpiechart.pro
new file mode 100644
index 00000000..926f9c2d
--- /dev/null
+++ b/examples/charts/qmlpiechart/qmlpiechart.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlpiechart/*
diff --git a/examples/charts/qmlpiechart/qmlpiechart.svg b/examples/charts/qmlpiechart/qmlpiechart.svg
new file mode 100644
index 00000000..566acfad
--- /dev/null
+++ b/examples/charts/qmlpiechart/qmlpiechart.svg
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="44px"
+ version="1.1"
+ viewBox="0 0 44 44"
+ width="44px"
+ x="0px"
+ y="0px"
+ id="svg2"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="qt.svg">
+ <metadata
+ id="metadata18">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs16">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 22 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="44 : 22 : 1"
+ inkscape:persp3d-origin="22 : 14.666667 : 1"
+ id="perspective2836" />
+ </defs>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1020"
+ id="namedview14"
+ showgrid="false"
+ inkscape:zoom="21.454545"
+ inkscape:cx="49.412871"
+ inkscape:cy="21.894358"
+ inkscape:window-x="-4"
+ inkscape:window-y="-4"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g3" />
+ <g
+ transform="matrix(0.18308778,0,0,0.18308778,6.6100946,3.2385199)"
+ id="g3">
+ <path
+ d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
+ style="fill:#006225"
+ id="path5"
+ sodipodi:nodetypes="cccccccc" />
+ <path
+ d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
+ style="fill:#80c342"
+ id="path7" />
+ <path
+ d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
+ style="fill:#006225"
+ id="path11" />
+ <path
+ d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
+ style="fill:#006225"
+ id="path13" />
+ <path
+ id="path17"
+ style="fill:#ffffff"
+ d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z" />
+ <path
+ d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
+ style="fill:#006225"
+ id="path19" />
+ <path
+ id="path21"
+ style="fill:#006225"
+ d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z" />
+ </g>
+</svg>
diff --git a/examples/charts/qmlpiechart/resources.qrc b/examples/charts/qmlpiechart/resources.qrc
new file mode 100644
index 00000000..2501bcc8
--- /dev/null
+++ b/examples/charts/qmlpiechart/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlpiechart/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlpolarchart/main.cpp b/examples/charts/qmlpolarchart/main.cpp
new file mode 100644
index 00000000..a850da1f
--- /dev/null
+++ b/examples/charts/qmlpolarchart/main.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ viewer.setTitle(QStringLiteral("QML Polar Chart"));
+ viewer.setSource(QUrl("qrc:/qml/qmlpolarchart/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml
new file mode 100644
index 00000000..b6c921fa
--- /dev/null
+++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View1.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+ //![1]
+ PolarChartView {
+ title: "Two Series, Common Axes"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ ValueAxis {
+ id: axisAngular
+ min: 0
+ max: 20
+ tickCount: 9
+ }
+
+ ValueAxis {
+ id: axisRadial
+ min: -0.5
+ max: 1.5
+ }
+
+ SplineSeries {
+ id: series1
+ axisAngular: axisAngular
+ axisRadial: axisRadial
+ pointsVisible: true
+ }
+
+ ScatterSeries {
+ id: series2
+ axisAngular: axisAngular
+ axisRadial: axisRadial
+ markerSize: 10
+ }
+ }
+
+ // Add data dynamically to the series
+ Component.onCompleted: {
+ for (var i = 0; i <= 20; i++) {
+ series1.append(i, Math.random());
+ series2.append(i, Math.random());
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml
new file mode 100644
index 00000000..9df1f66b
--- /dev/null
+++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View2.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ PolarChartView {
+ title: "Historical Area Series"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ DateTimeAxis {
+ id: axis1
+ format: "yyyy MMM"
+ tickCount: 13
+ }
+ ValueAxis {
+ id: axis2
+ }
+ LineSeries {
+ id: lowerLine
+ axisAngular: axis1
+ axisRadial: axis2
+
+ // Please note that month in JavaScript months are zero based, so 2 means March
+ XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 15 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 35 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 50 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 75 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 102 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 132 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 100 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 120 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 140 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 150 }
+ }
+ LineSeries {
+ id: upperLine
+ axisAngular: axis1
+ axisRadial: axis2
+
+ // Please note that month in JavaScript months are zero based, so 2 means March
+ XYPoint { x: toMsecsSinceEpoch(new Date(1950, 0, 1)); y: 30 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1962, 4, 1)); y: 55 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1970, 0, 1)); y: 80 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1978, 2, 1)); y: 105 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1987, 11, 1)); y: 125 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1992, 1, 1)); y: 160 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(1998, 7, 1)); y: 140 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2002, 4, 1)); y: 140 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2012, 8, 1)); y: 170 }
+ XYPoint { x: toMsecsSinceEpoch(new Date(2013, 5, 1)); y: 200 }
+ }
+ AreaSeries {
+ axisAngular: axis1
+ axisRadial: axis2
+ lowerSeries: lowerLine
+ upperSeries: upperLine
+ }
+ }
+ // DateTimeAxis is based on QDateTimes so we must convert our JavaScript dates to
+ // milliseconds since epoch to make them match the DateTimeAxis values
+ function toMsecsSinceEpoch(date) {
+ var msecs = date.getTime();
+ return msecs;
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml
new file mode 100644
index 00000000..0a5304b4
--- /dev/null
+++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/View3.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ anchors.fill: parent
+
+ //![1]
+ PolarChartView {
+ title: "Numerical Data for Dummies"
+ anchors.fill: parent
+ legend.visible: false
+ antialiasing: true
+
+ LineSeries {
+ axisRadial: CategoryAxis {
+ min: 0
+ max: 30
+ CategoryRange {
+ label: "critical"
+ endValue: 2
+ }
+ CategoryRange {
+ label: "low"
+ endValue: 7
+ }
+ CategoryRange {
+ label: "normal"
+ endValue: 12
+ }
+ CategoryRange {
+ label: "high"
+ endValue: 18
+ }
+ CategoryRange {
+ label: "extremely high"
+ endValue: 30
+ }
+ }
+
+ axisAngular: ValueAxis {
+ tickCount: 13
+ }
+
+ XYPoint { x: 0; y: 4.3 }
+ XYPoint { x: 1; y: 4.1 }
+ XYPoint { x: 2; y: 4.7 }
+ XYPoint { x: 3; y: 3.9 }
+ XYPoint { x: 4; y: 5.2 }
+ XYPoint { x: 5; y: 5.3 }
+ XYPoint { x: 6; y: 6.1 }
+ XYPoint { x: 7; y: 7.7 }
+ XYPoint { x: 8; y: 12.9 }
+ XYPoint { x: 9; y: 19.2 }
+ }
+ }
+ //![1]
+}
diff --git a/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml b/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml
new file mode 100644
index 00000000..ce5a4ed4
--- /dev/null
+++ b/examples/charts/qmlpolarchart/qml/qmlpolarchart/main.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 800
+ height: 600
+ property bool sourceLoaded: false
+
+ ListView {
+ id: root
+ focus: true
+ anchors.fill: parent
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightMoveDuration: 250
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+
+ onCurrentIndexChanged: {
+ if (infoText.opacity > 0.0) {
+ if (sourceLoaded)
+ infoText.opacity = 0.0;
+ else if (currentIndex != 0)
+ currentIndex = 0;
+ }
+ }
+
+ model: ListModel {
+ ListElement {component: "View1.qml"}
+ ListElement {component: "View2.qml"}
+ ListElement {component: "View3.qml"}
+ }
+
+ delegate: Loader {
+ width: root.width
+ height: root.height
+
+ source: component
+ asynchronous: true
+
+ onLoaded: sourceLoaded = true
+ }
+ }
+
+ Rectangle {
+ id: infoText
+ anchors.centerIn: parent
+ width: parent.width
+ height: 40
+ color: "black"
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: "You can navigate between views using swipe or arrow keys"
+ }
+
+ Behavior on opacity {
+ NumberAnimation { duration: 400 }
+ }
+ }
+}
diff --git a/examples/charts/qmlpolarchart/qmlpolarchart.pro b/examples/charts/qmlpolarchart/qmlpolarchart.pro
new file mode 100644
index 00000000..aa3341a5
--- /dev/null
+++ b/examples/charts/qmlpolarchart/qmlpolarchart.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlpolarchart/*
diff --git a/examples/charts/qmlpolarchart/resources.qrc b/examples/charts/qmlpolarchart/resources.qrc
new file mode 100644
index 00000000..a4a975ed
--- /dev/null
+++ b/examples/charts/qmlpolarchart/resources.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlpolarchart/main.qml</file>
+ <file>qml/qmlpolarchart/View1.qml</file>
+ <file>qml/qmlpolarchart/View2.qml</file>
+ <file>qml/qmlpolarchart/View3.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/qmlweather/main.cpp b/examples/charts/qmlweather/main.cpp
new file mode 100644
index 00000000..9bdd28d1
--- /dev/null
+++ b/examples/charts/qmlweather/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** 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 <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QDebug>
+#include <QtCore/QDir>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+
+int main(int argc, char *argv[])
+{
+ // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
+ QApplication app(argc, argv);
+
+ QQuickView viewer;
+ // The following are needed to make examples run without having to install the module
+ // in desktop environments.
+#ifdef Q_OS_WIN
+ QString extraImportPath(QStringLiteral("%1/../../../../%2"));
+#else
+ QString extraImportPath(QStringLiteral("%1/../../../%2"));
+#endif
+ viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+ QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
+
+ QString appKey;
+ if (argc > 1) {
+ appKey = argv[1];
+ qDebug() << "App key for worldweatheronline.com:" << appKey;
+ } else {
+ qWarning() << "No app key for worldweatheronline.com given. Using static test data instead of live data.";
+ }
+ viewer.setTitle(QStringLiteral("QML Weather"));
+ viewer.rootContext()->setContextProperty("weatherAppKey", appKey);
+ viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/charts/qmlweather/qml/qmlweather/main.qml b/examples/charts/qmlweather/qml/qmlweather/main.qml
new file mode 100644
index 00000000..23d3ee23
--- /dev/null
+++ b/examples/charts/qmlweather/qml/qmlweather/main.qml
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtCharts 2.0
+
+Rectangle {
+ width: 500
+ height: 400
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightblue" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+
+ //![1]
+ ChartView {
+ id: chartView
+ title: "Weather forecast"
+ //![1]
+ anchors.top: parent.top
+ anchors.bottom: weatherImageRow.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ legend.alignment: Qt.AlignTop
+ antialiasing: true
+
+ //![2]
+ BarCategoryAxis {
+ id: barCategoriesAxis
+ titleText: "Date"
+ }
+
+ ValueAxis{
+ id: valueAxisY2
+ min: 0
+ max: 10
+ titleText: "Rainfall [mm]"
+ }
+
+ ValueAxis {
+ id: valueAxisX
+ // Hide the value axis; it is only used to map the line series to bar categories axis
+ visible: false
+ min: 0
+ max: 5
+ }
+
+ ValueAxis{
+ id: valueAxisY
+ min: 0
+ max: 15
+ titleText: "Temperature [&deg;C]"
+ }
+
+ LineSeries {
+ id: maxTempSeries
+ axisX: valueAxisX
+ axisY: valueAxisY
+ name: "Max. temperature"
+ }
+
+ LineSeries {
+ id: minTempSeries
+ axisX: valueAxisX
+ axisY: valueAxisY
+ name: "Min. temperature"
+ }
+
+ BarSeries {
+ id: myBarSeries
+ axisX: barCategoriesAxis
+ axisYRight: valueAxisY2
+ BarSet {
+ id: rainfallSet
+ label: "Rainfall"
+ }
+ }
+ //![2]
+ }
+
+ // A timer to refresh the forecast every 5 minutes
+ Timer {
+ interval: 300000
+ repeat: true
+ triggeredOnStart: true
+ running: true
+ onTriggered: {
+ if (weatherAppKey != "") {
+ //![3]
+ // Make HTTP GET request and parse the result
+ var xhr = new XMLHttpRequest;
+ xhr.open("GET",
+ "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
+ + weatherAppKey);
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == XMLHttpRequest.DONE) {
+ var a = JSON.parse(xhr.responseText);
+ parseWeatherData(a);
+ }
+ }
+ xhr.send();
+ //![3]
+ } else {
+ // No app key for worldweatheronline.com given by the user -> use dummy static data
+ var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}";
+ var a = JSON.parse(responseText);
+ parseWeatherData(a);
+ }
+ }
+ }
+
+ Row {
+ id: weatherImageRow
+ anchors.bottom: poweredByText.top
+ anchors.bottomMargin: 10
+ anchors.left: parent.left
+ anchors.leftMargin: 25
+ anchors.right: parent.right
+ anchors.rightMargin: 25
+
+ ListModel {
+ id: weatherImageModel
+ }
+
+ Repeater {
+ id: repeater
+ model: weatherImageModel
+ delegate: Image {
+ source: imageSource
+ width: weatherImageRow.width / weatherImageModel.count
+ height: width
+ fillMode: Image.PreserveAspectCrop
+ }
+ }
+ }
+
+ Text {
+ id: poweredByText
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 10
+ anchors.left: parent.left
+ anchors.leftMargin: 25
+ text: "Powered by World Weather Online"
+ }
+
+ function parseWeatherData(weatherData) {
+ // Clear previous values
+ maxTempSeries.clear();
+ minTempSeries.clear();
+ weatherImageModel.clear();
+
+ //![4]
+ // Loop through the parsed JSON
+ for (var i in weatherData.data.weather) {
+ var weatherObj = weatherData.data.weather[i];
+ //![4]
+
+ //![5]
+ // Store temperature values, rainfall and weather icon.
+ // The temperature values begin from 0.5 instead of 0.0 to make the start from the
+ // middle of the rainfall bars. This makes the temperature lines visually better
+ // synchronized with the rainfall bars.
+ maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
+ minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
+ rainfallSet.append(i, weatherObj.precipMM);
+ weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
+ //![5]
+
+ // Update scale of the chart
+ valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
+ valueAxisX.min = 0;
+ valueAxisX.max = Number(i) + 1;
+
+ // Set the x-axis labels to the dates of the forecast
+ var xLabels = barCategoriesAxis.categories;
+ xLabels[Number(i)] = weatherObj.date.substring(5, 10);
+ barCategoriesAxis.categories = xLabels;
+ barCategoriesAxis.visible = true;
+ barCategoriesAxis.min = 0;
+ barCategoriesAxis.max = xLabels.length - 1;
+ }
+ }
+
+}
diff --git a/examples/charts/qmlweather/qmlweather.pro b/examples/charts/qmlweather/qmlweather.pro
new file mode 100644
index 00000000..5e0d8df4
--- /dev/null
+++ b/examples/charts/qmlweather/qmlweather.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+RESOURCES += resources.qrc
+SOURCES += main.cpp
+OTHER_FILES += qml/qmlweather/*
diff --git a/examples/charts/qmlweather/resources.qrc b/examples/charts/qmlweather/resources.qrc
new file mode 100644
index 00000000..7205906f
--- /dev/null
+++ b/examples/charts/qmlweather/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlweather/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/scatterchart/chartview.cpp b/examples/charts/scatterchart/chartview.cpp
new file mode 100644
index 00000000..345be195
--- /dev/null
+++ b/examples/charts/scatterchart/chartview.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <QScatterSeries>
+#include <QLegendMarker>
+#include <QImage>
+#include <QPainter>
+#include <qmath.h>
+
+const float Pi = 3.14159f;
+
+ChartView::ChartView(QWidget *parent) :
+ QChartView(new QChart(), parent)
+{
+ //![1]
+ QScatterSeries *series0 = new QScatterSeries();
+ series0->setName("scatter1");
+ series0->setMarkerShape(QScatterSeries::MarkerShapeCircle);
+ series0->setMarkerSize(15.0);
+
+ QScatterSeries *series1 = new QScatterSeries();
+ series1->setName("scatter2");
+ series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
+ series1->setMarkerSize(20.0);
+
+ QScatterSeries *series2 = new QScatterSeries();
+ series2->setName("scatter3");
+ series2->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
+ series2->setMarkerSize(30.0);
+ //![1]
+
+ //![2]
+ series0->append(0, 6);
+ series0->append(2, 4);
+ series0->append(3, 8);
+ series0->append(7, 4);
+ series0->append(10, 5);
+
+ *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2);
+ *series2 << QPointF(1, 5) << QPointF(4, 6) << QPointF(6, 3) << QPointF(9, 5);
+ //![2]
+
+ //![3]
+ QPainterPath starPath;
+ starPath.moveTo(30, 15);
+ for (int i = 1; i < 5; ++i) {
+ starPath.lineTo(15 + 15 * qCos(0.8 * i * Pi),
+ 15 + 15 * qSin(0.8 * i * Pi));
+ }
+ starPath.closeSubpath();
+
+ QImage star(30, 30, QImage::Format_ARGB32);
+ star.fill(Qt::transparent);
+
+ QPainter painter(&star);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(QRgb(0xf6a625));
+ painter.setBrush(painter.pen().color());
+ painter.drawPath(starPath);
+
+ series2->setBrush(star);
+ //![3]
+
+ //![4]
+ setRenderHint(QPainter::Antialiasing);
+ chart()->addSeries(series0);
+ chart()->addSeries(series1);
+ chart()->addSeries(series2);
+
+ chart()->setTitle("Simple scatterchart example");
+ chart()->createDefaultAxes();
+ chart()->setDropShadowEnabled(false);
+ //![4]
+
+ //![5]
+ QList<QLegendMarker *> markers = chart()->legend()->markers(series2);
+ for (int i = 0; i < markers.count(); i++)
+ markers.at(i)->setBrush(painter.pen().color());
+ //![5]
+}
diff --git a/examples/charts/scatterchart/chartview.h b/examples/charts/scatterchart/chartview.h
new file mode 100644
index 00000000..c2c03038
--- /dev/null
+++ b/examples/charts/scatterchart/chartview.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** 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 CHARTVIEW_H
+#define CHARTVIEW_H
+
+#include <QChartView>
+
+QT_CHARTS_USE_NAMESPACE
+
+class ChartView : public QChartView
+{
+ Q_OBJECT
+public:
+ explicit ChartView(QWidget *parent = 0);
+};
+
+#endif // CHARTVIEW_H
diff --git a/examples/charts/scatterchart/main.cpp b/examples/charts/scatterchart/main.cpp
new file mode 100644
index 00000000..e1a76ed2
--- /dev/null
+++ b/examples/charts/scatterchart/main.cpp
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![4]
+ ChartView *chartView = new ChartView();
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+//![4]
+
+ return a.exec();
+}
diff --git a/examples/charts/scatterchart/scatterchart.pro b/examples/charts/scatterchart/scatterchart.pro
new file mode 100644
index 00000000..8170d6f4
--- /dev/null
+++ b/examples/charts/scatterchart/scatterchart.pro
@@ -0,0 +1,9 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = scatterchart
+SOURCES += main.cpp \
+ chartview.cpp
+
+HEADERS += \
+ chartview.h
diff --git a/examples/charts/scatterinteractions/chartview.cpp b/examples/charts/scatterinteractions/chartview.cpp
new file mode 100644
index 00000000..7e55c4e0
--- /dev/null
+++ b/examples/charts/scatterinteractions/chartview.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <qmath.h>
+#include <QDebug>
+
+QT_CHARTS_USE_NAMESPACE
+
+ChartView::ChartView(QWidget *parent)
+ : QChartView(new QChart(), parent),
+ m_scatter(0),
+ m_scatter2(0)
+{
+ setRenderHint(QPainter::Antialiasing);
+
+ chart()->setTitle("Click to interact with scatter points");
+
+ m_scatter = new QScatterSeries();
+ m_scatter->setName("scatter1");
+ for (qreal x(0.5); x <= 4.0; x += 0.5) {
+ for (qreal y(0.5); y <= 4.0; y += 0.5) {
+ *m_scatter << QPointF(x, y);
+ }
+ }
+ m_scatter2 = new QScatterSeries();
+ m_scatter2->setName("scatter2");
+
+ chart()->addSeries(m_scatter2);
+ chart()->addSeries(m_scatter);
+ chart()->createDefaultAxes();
+ chart()->axisX()->setRange(0, 4.5);
+ chart()->axisY()->setRange(0, 4.5);
+
+ connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(handleClickedPoint(QPointF)));
+}
+
+ChartView::~ChartView()
+{
+}
+
+void ChartView::handleClickedPoint(const QPointF &point)
+{
+ QPointF clickedPoint = point;
+ // Find the closest point from series 1
+ QPointF closest(INT_MAX, INT_MAX);
+ qreal distance(INT_MAX);
+ foreach (QPointF currentPoint, m_scatter->points()) {
+ qreal currentDistance = qSqrt((currentPoint.x() - clickedPoint.x())
+ * (currentPoint.x() - clickedPoint.x())
+ + (currentPoint.y() - clickedPoint.y())
+ * (currentPoint.y() - clickedPoint.y()));
+ if (currentDistance < distance) {
+ distance = currentDistance;
+ closest = currentPoint;
+ }
+ }
+
+ // Remove the closes point from series 1 and append it to series 2
+ m_scatter->remove(closest);
+ m_scatter2->append(closest);
+}
diff --git a/examples/charts/scatterinteractions/chartview.h b/examples/charts/scatterinteractions/chartview.h
new file mode 100644
index 00000000..da280051
--- /dev/null
+++ b/examples/charts/scatterinteractions/chartview.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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 CHARTVIEW_H
+#define CHARTVIEW_H
+
+#include <QChartGlobal>
+#include <QChartView>
+#include <QScatterSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+class ChartView : public QChartView
+{
+ Q_OBJECT
+
+public:
+ ChartView(QWidget *parent = 0);
+ ~ChartView();
+
+private Q_SLOTS:
+ void handleClickedPoint(const QPointF &point);
+
+private:
+ QScatterSeries *m_scatter;
+ QScatterSeries *m_scatter2;
+};
+
+#endif // CHARTVIEW_H
diff --git a/examples/charts/scatterinteractions/main.cpp b/examples/charts/scatterinteractions/main.cpp
new file mode 100644
index 00000000..fb5dd8fc
--- /dev/null
+++ b/examples/charts/scatterinteractions/main.cpp
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow window;
+ ChartView chartView(&window);
+ window.setCentralWidget(&chartView);
+ window.resize(400, 300);
+ window.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/scatterinteractions/scatterinteractions.pro b/examples/charts/scatterinteractions/scatterinteractions.pro
new file mode 100644
index 00000000..596fe020
--- /dev/null
+++ b/examples/charts/scatterinteractions/scatterinteractions.pro
@@ -0,0 +1,9 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = scatterinteractions
+SOURCES += main.cpp \
+ chartview.cpp
+HEADERS += \
+ chartview.h
diff --git a/examples/charts/splinechart/main.cpp b/examples/charts/splinechart/main.cpp
new file mode 100644
index 00000000..e6a40dd0
--- /dev/null
+++ b/examples/charts/splinechart/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 <QSplineSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ //![1]
+ QSplineSeries *series = new QSplineSeries();
+ series->setName("spline");
+ //![1]
+
+ //![2]
+ series->append(0, 6);
+ series->append(2, 4);
+ series->append(3, 8);
+ series->append(7, 4);
+ series->append(10, 5);
+ *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
+ //![2]
+
+ //![3]
+ QChart *chart = new QChart();
+ chart->legend()->hide();
+ chart->addSeries(series);
+ chart->setTitle("Simple spline chart example");
+ chart->createDefaultAxes();
+ chart->axisY()->setRange(0, 10);
+ //![3]
+
+ //![4]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ //![4]
+
+ //![5]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.show();
+ //![5]
+
+ return a.exec();
+}
diff --git a/examples/charts/splinechart/splinechart.pro b/examples/charts/splinechart/splinechart.pro
new file mode 100644
index 00000000..b2624f53
--- /dev/null
+++ b/examples/charts/splinechart/splinechart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = splinechart
+SOURCES += main.cpp
diff --git a/examples/charts/stackedbarchart/main.cpp b/examples/charts/stackedbarchart/main.cpp
new file mode 100644
index 00000000..c94b18de
--- /dev/null
+++ b/examples/charts/stackedbarchart/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 <QStackedBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *set0 = new QBarSet("Jane");
+ QBarSet *set1 = new QBarSet("John");
+ QBarSet *set2 = new QBarSet("Axel");
+ QBarSet *set3 = new QBarSet("Mary");
+ QBarSet *set4 = new QBarSet("Samantha");
+
+ *set0 << 1 << 2 << 3 << 4 << 5 << 6;
+ *set1 << 5 << 0 << 0 << 4 << 0 << 7;
+ *set2 << 3 << 5 << 8 << 13 << 8 << 5;
+ *set3 << 5 << 6 << 7 << 3 << 4 << 5;
+ *set4 << 9 << 7 << 5 << 3 << 1 << 2;
+//![1]
+
+//![2]
+ QStackedBarSeries *series = new QStackedBarSeries();
+ series->append(set0);
+ series->append(set1);
+ series->append(set2);
+ series->append(set3);
+ series->append(set4);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Simple stackedbarchart example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun";
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ chart->createDefaultAxes();
+ chart->setAxisX(axis, series);
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(420, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
+
diff --git a/examples/charts/stackedbarchart/stackedbarchart.pro b/examples/charts/stackedbarchart/stackedbarchart.pro
new file mode 100644
index 00000000..f6a77b6a
--- /dev/null
+++ b/examples/charts/stackedbarchart/stackedbarchart.pro
@@ -0,0 +1,5 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = stackedbarchart
+SOURCES += main.cpp
diff --git a/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp b/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp
new file mode 100644
index 00000000..1acfa172
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/drilldownchart.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 "drilldownchart.h"
+#include <QBarCategoryAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QChart(QChart::ChartTypeCartesian, parent, wFlags),
+ m_currentSeries(0)
+{
+}
+
+void DrilldownChart::changeSeries(DrilldownBarSeries *series)
+{
+ if (m_currentSeries) {
+ removeSeries(m_currentSeries);
+ }
+
+ m_currentSeries = series;
+
+ // Reset axis
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(m_currentSeries->categories());
+
+ addSeries(series);
+
+ createDefaultAxes();
+ setAxisX(axis, series);
+ axisY()->setTitleText("Crops");
+
+ setTitle(series->name());
+}
+
+void DrilldownChart::handleClicked(int index, QBarSet *barset)
+{
+ Q_UNUSED(barset)
+ DrilldownBarSeries *series = static_cast<DrilldownBarSeries *>(sender());
+ changeSeries(series->drilldownSeries(index));
+}
+
+#include "moc_drilldownchart.cpp"
diff --git a/examples/charts/stackedbarchartdrilldown/drilldownchart.h b/examples/charts/stackedbarchartdrilldown/drilldownchart.h
new file mode 100644
index 00000000..c75216f7
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/drilldownchart.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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 DRILLDOWNCHART_H
+#define DRILLDOWNCHART_H
+
+#include <QChart>
+#include "drilldownseries.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+//! [1]
+class DrilldownChart : public QChart
+{
+ Q_OBJECT
+public:
+ explicit DrilldownChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+
+ void changeSeries(DrilldownBarSeries *series);
+
+public Q_SLOTS:
+ void handleClicked(int index, QBarSet *barset);
+
+private:
+ DrilldownBarSeries *m_currentSeries;
+};
+//! [1]
+
+#endif // DRILLDOWNCHART_H
diff --git a/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp b/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp
new file mode 100644
index 00000000..87d70b5a
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/drilldownseries.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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 "drilldownseries.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+DrilldownBarSeries::DrilldownBarSeries(QStringList categories, QObject *parent)
+ : QStackedBarSeries(parent)
+{
+ m_categories = categories;
+}
+
+void DrilldownBarSeries::mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries)
+{
+ m_DrilldownSeries[index] = drilldownSeries;
+}
+
+DrilldownBarSeries *DrilldownBarSeries::drilldownSeries(int index)
+{
+ return m_DrilldownSeries[index];
+}
+
+QStringList DrilldownBarSeries::categories()
+{
+ return m_categories;
+}
+
+#include "moc_drilldownseries.cpp"
diff --git a/examples/charts/stackedbarchartdrilldown/drilldownseries.h b/examples/charts/stackedbarchartdrilldown/drilldownseries.h
new file mode 100644
index 00000000..5a340839
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/drilldownseries.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 DRILLDOWNSERIES_H
+#define DRILLDOWNSERIES_H
+
+#include <QStackedBarSeries>
+#include <QMap>
+
+QT_CHARTS_USE_NAMESPACE
+
+//! [1]
+class DrilldownBarSeries : public QStackedBarSeries
+{
+ Q_OBJECT
+public:
+ DrilldownBarSeries(QStringList categories, QObject *parent = 0);
+
+ void mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries);
+
+ DrilldownBarSeries *drilldownSeries(int index);
+
+ QStringList categories();
+
+private:
+ QMap<int, DrilldownBarSeries *> m_DrilldownSeries;
+ QStringList m_categories;
+};
+//! [1]
+
+#endif // DRILLDOWNSERIES_H
diff --git a/examples/charts/stackedbarchartdrilldown/main.cpp b/examples/charts/stackedbarchartdrilldown/main.cpp
new file mode 100644
index 00000000..6a46520d
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/main.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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 <QBarSet>
+#include <QLegend>
+#include "drilldownseries.h"
+#include "drilldownchart.h"
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow window;
+
+//! [1]
+ DrilldownChart *drilldownChart = new DrilldownChart();
+ drilldownChart->setTheme(QChart::ChartThemeBlueIcy);
+ drilldownChart->setAnimationOptions(QChart::SeriesAnimations);
+//! [1]
+
+//! [2]
+ // Define categories
+ QStringList months;
+ months << "May" << "Jun" << "Jul" << "Aug" << "Sep";
+ QStringList weeks;
+ weeks << "week 1" << "week 2" << "week 3" << "week 4";
+ QStringList plants;
+ plants << "Habanero" << "Lemon Drop" << "Starfish" << "Aji Amarillo";
+//! [2]
+
+//! [3]
+ // Create drilldown structure
+ DrilldownBarSeries *seasonSeries = new DrilldownBarSeries(months, drilldownChart);
+ seasonSeries->setName("Crop by month - Season");
+
+ // Each month in season series has drilldown series for weekly data
+ for (int month = 0; month < months.count(); month++) {
+
+ // Create drilldown series for every week
+ DrilldownBarSeries *weeklySeries = new DrilldownBarSeries(weeks, drilldownChart);
+ seasonSeries->mapDrilldownSeries(month, weeklySeries);
+
+ // Drilling down from weekly data brings us back to season data.
+ for (int week = 0; week < weeks.count(); week++) {
+ weeklySeries->mapDrilldownSeries(week, seasonSeries);
+ weeklySeries->setName(QString("Crop by week - " + months.at(month)));
+ }
+
+ // Use clicked signal to implement drilldown
+ QObject::connect(weeklySeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*)));
+ }
+
+ // Enable drilldown from season series using clicked signal
+ QObject::connect(seasonSeries, SIGNAL(clicked(int,QBarSet*)), drilldownChart, SLOT(handleClicked(int,QBarSet*)));
+//! [3]
+
+//! [4]
+ // Fill monthly and weekly series with data
+ foreach (QString plant, plants) {
+ QBarSet *monthlyCrop = new QBarSet(plant);
+ for (int month = 0; month < months.count(); month++) {
+ QBarSet *weeklyCrop = new QBarSet(plant);
+ for (int week = 0; week < weeks.count(); week++)
+ *weeklyCrop << (qrand() % 20);
+ // Get the drilldown series from season series and add crop to it.
+ seasonSeries->drilldownSeries(month)->append(weeklyCrop);
+ *monthlyCrop << weeklyCrop->sum();
+ }
+ seasonSeries->append(monthlyCrop);
+ }
+//! [4]
+
+//! [5]
+ // Show season series in initial view
+ drilldownChart->changeSeries(seasonSeries);
+ drilldownChart->setTitle(seasonSeries->name());
+//! [5]
+
+//! [6]
+ drilldownChart->axisX()->setGridLineVisible(false);
+ drilldownChart->legend()->setVisible(true);
+ drilldownChart->legend()->setAlignment(Qt::AlignBottom);
+//! [6]
+
+ QChartView *chartView = new QChartView(drilldownChart);
+ window.setCentralWidget(chartView);
+ window.resize(480, 300);
+ window.show();
+
+ return a.exec();
+}
+
diff --git a/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro b/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro
new file mode 100644
index 00000000..c10066f4
--- /dev/null
+++ b/examples/charts/stackedbarchartdrilldown/stackedbarchartdrilldown.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = stackedbarchartdrilldown
+SOURCES += main.cpp drilldownseries.cpp drilldownchart.cpp
+HEADERS += drilldownseries.h drilldownchart.h
diff --git a/examples/charts/temperaturerecords/main.cpp b/examples/charts/temperaturerecords/main.cpp
new file mode 100644
index 00000000..24caec8e
--- /dev/null
+++ b/examples/charts/temperaturerecords/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** 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 <QBarSeries>
+#include <QBarSet>
+#include <QLegend>
+#include <QBarCategoryAxis>
+#include <QStackedBarSeries>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QBarSet *low = new QBarSet("Min");
+ QBarSet *high = new QBarSet("Max");
+
+ *low << -52 << -50 << -45.3 << -37.0 << -25.6 << -8.0 << -6.0 << -11.8 << -19.7 << -32.8 << -43.0 << -48.0;
+ *high << 11.9 << 12.8 << 18.5 << 26.5 << 32.0 << 34.8 << 38.2 << 34.8 << 29.8 << 20.4 << 15.1 << 11.8;
+//![1]
+
+//![2]
+ QStackedBarSeries *series = new QStackedBarSeries();
+ series->append(low);
+ series->append(high);
+//![2]
+
+//![3]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle("Temperature records in celcius");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+//![3]
+
+//![4]
+ QStringList categories;
+ categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
+
+ QBarCategoryAxis *axis = new QBarCategoryAxis();
+ axis->append(categories);
+ axis->setTitleText("Month");
+ chart->createDefaultAxes();
+ chart->setAxisX(axis, series);
+ chart->axisY(series)->setRange(-52, 52);
+ chart->axisY(series)->setTitleText("Temperature [&deg;C]");
+//![4]
+
+//![5]
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+//![5]
+
+//![6]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+//![6]
+
+//![7]
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(600, 300);
+ window.show();
+//![7]
+
+ return a.exec();
+}
diff --git a/examples/charts/temperaturerecords/temperaturerecords.pro b/examples/charts/temperaturerecords/temperaturerecords.pro
new file mode 100644
index 00000000..e2eb6be3
--- /dev/null
+++ b/examples/charts/temperaturerecords/temperaturerecords.pro
@@ -0,0 +1,6 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+TARGET = temperaturerecords
+SOURCES += main.cpp
diff --git a/examples/charts/zoomlinechart/chart.cpp b/examples/charts/zoomlinechart/chart.cpp
new file mode 100644
index 00000000..890c6c03
--- /dev/null
+++ b/examples/charts/zoomlinechart/chart.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 "chart.h"
+#include <QGesture>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+
+Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QChart(QChart::ChartTypeCartesian, parent, wFlags)
+{
+ // Seems that QGraphicsView (QChartView) does not grab gestures.
+ // They can only be grabbed here in the QGraphicsWidget (QChart).
+ grabGesture(Qt::PanGesture);
+ grabGesture(Qt::PinchGesture);
+}
+
+Chart::~Chart()
+{
+
+}
+
+//![1]
+bool Chart::sceneEvent(QEvent *event)
+{
+ if (event->type() == QEvent::Gesture)
+ return gestureEvent(static_cast<QGestureEvent *>(event));
+ return QChart::event(event);
+}
+
+bool Chart::gestureEvent(QGestureEvent *event)
+{
+ if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
+ QPanGesture *pan = static_cast<QPanGesture *>(gesture);
+ QChart::scroll(-(pan->delta().x()), pan->delta().y());
+ }
+
+ if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
+ QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
+ if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged)
+ QChart::zoom(pinch->scaleFactor());
+ }
+
+ return true;
+}
+//![1]
diff --git a/examples/charts/zoomlinechart/chart.h b/examples/charts/zoomlinechart/chart.h
new file mode 100644
index 00000000..a0ebb223
--- /dev/null
+++ b/examples/charts/zoomlinechart/chart.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 CHART_H
+#define CHART_H
+
+#include <QChart>
+
+class QGestureEvent;
+
+QT_CHARTS_USE_NAMESPACE
+
+//![1]
+class Chart : public QChart
+//![1]
+{
+public:
+ explicit Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ ~Chart();
+
+protected:
+ bool sceneEvent(QEvent *event);
+
+private:
+ bool gestureEvent(QGestureEvent *event);
+
+private:
+
+};
+
+#endif // CHART_H
diff --git a/examples/charts/zoomlinechart/chartview.cpp b/examples/charts/zoomlinechart/chartview.cpp
new file mode 100644
index 00000000..64369c62
--- /dev/null
+++ b/examples/charts/zoomlinechart/chartview.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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 "chartview.h"
+#include <QMouseEvent>
+
+ChartView::ChartView(QChart *chart, QWidget *parent) :
+ QChartView(chart, parent),
+ m_isTouching(false)
+{
+ setRubberBand(QChartView::RectangleRubberBand);
+}
+
+bool ChartView::viewportEvent(QEvent *event)
+{
+ if (event->type() == QEvent::TouchBegin) {
+ // By default touch events are converted to mouse events. So
+ // after this event we will get a mouse event also but we want
+ // to handle touch events as gestures only. So we need this safeguard
+ // to block mouse events that are actually generated from touch.
+ m_isTouching = true;
+
+ // Turn off animations when handling gestures they
+ // will only slow us down.
+ chart()->setAnimationOptions(QChart::NoAnimation);
+ }
+ return QChartView::viewportEvent(event);
+}
+
+void ChartView::mousePressEvent(QMouseEvent *event)
+{
+ if (m_isTouching)
+ return;
+ QChartView::mousePressEvent(event);
+}
+
+void ChartView::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_isTouching)
+ return;
+ QChartView::mouseMoveEvent(event);
+}
+
+void ChartView::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (m_isTouching)
+ m_isTouching = false;
+
+ // Because we disabled animations when touch event was detected
+ // we must put them back on.
+ chart()->setAnimationOptions(QChart::SeriesAnimations);
+
+ QChartView::mouseReleaseEvent(event);
+}
+
+//![1]
+void ChartView::keyPressEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_Plus:
+ chart()->zoomIn();
+ break;
+ case Qt::Key_Minus:
+ chart()->zoomOut();
+ break;
+//![1]
+ case Qt::Key_Left:
+ chart()->scroll(-10, 0);
+ break;
+ case Qt::Key_Right:
+ chart()->scroll(10, 0);
+ break;
+ case Qt::Key_Up:
+ chart()->scroll(0, 10);
+ break;
+ case Qt::Key_Down:
+ chart()->scroll(0, -10);
+ break;
+ default:
+ QGraphicsView::keyPressEvent(event);
+ break;
+ }
+}
diff --git a/examples/charts/zoomlinechart/chartview.h b/examples/charts/zoomlinechart/chartview.h
new file mode 100644
index 00000000..3ad7c85e
--- /dev/null
+++ b/examples/charts/zoomlinechart/chartview.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 CHARTVIEW_H
+#define CHARTVIEW_H
+
+#include <QChartView>
+#include <QRubberBand>
+
+QT_CHARTS_USE_NAMESPACE
+
+//![1]
+class ChartView : public QChartView
+//![1]
+{
+public:
+ ChartView(QChart *chart, QWidget *parent = 0);
+
+//![2]
+protected:
+ bool viewportEvent(QEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+//![2]
+
+private:
+ bool m_isTouching;
+};
+
+#endif
diff --git a/examples/charts/zoomlinechart/main.cpp b/examples/charts/zoomlinechart/main.cpp
new file mode 100644
index 00000000..7dd5865a
--- /dev/null
+++ b/examples/charts/zoomlinechart/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 "chart.h"
+#include "chartview.h"
+#include <QApplication>
+#include <QMainWindow>
+#include <qmath.h>
+#include <QLineSeries>
+#include <QValueAxis>
+
+QT_CHARTS_USE_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//![1]
+ QLineSeries *series = new QLineSeries();
+ for (int i = 0; i < 500; i++) {
+ QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100);
+ p.ry() += qrand() % 20;
+ *series << p;
+ }
+//![1]
+
+ Chart *chart = new Chart();
+ chart->addSeries(series);
+ chart->setTitle("Zoom in/out example");
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+ chart->legend()->hide();
+ chart->createDefaultAxes();
+
+ ChartView *chartView = new ChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+
+ QMainWindow window;
+ window.setCentralWidget(chartView);
+ window.resize(400, 300);
+ window.grabGesture(Qt::PanGesture);
+ window.grabGesture(Qt::PinchGesture);
+ window.show();
+
+ return a.exec();
+}
diff --git a/examples/charts/zoomlinechart/zoomlinechart.pro b/examples/charts/zoomlinechart/zoomlinechart.pro
new file mode 100644
index 00000000..c98161b2
--- /dev/null
+++ b/examples/charts/zoomlinechart/zoomlinechart.pro
@@ -0,0 +1,7 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+TARGET = zoomlinechart
+HEADERS += chart.h chartview.h
+
+SOURCES += main.cpp chart.cpp chartview.cpp