summaryrefslogtreecommitdiffstats
path: root/examples/charts/qmlaxes
diff options
context:
space:
mode:
authorTitta Heikkala <titta.heikkala@digia.com>2014-07-01 07:10:00 +0300
committerTitta Heikkala <titta.heikkala@theqtcompany.com>2014-10-14 13:04:52 +0300
commitc544258484ff4fd5d2b88402fbaa5d154b89a3a2 (patch)
tree7659625abb566dec55d3783ed820b928542d9b2b /examples/charts/qmlaxes
parent76339f714f088645e911cee65bdb66055fe029aa (diff)
Qt Charts project file structure change
Charts repository structure is changed to follow the structure of a Qt Add-On module. The task includes following changes: - All macros and definitions named 'commercial' have been renamed. - Compile errors related to QString and qSort usage have been fixed. - Old demos are moved under examples. The QML examples now support only Qt Quick 2.0, the support for Qt Quick 1 is removed. - The QML examples with multiple views are updated so that they are usable also with touch devices. - Unnecessary version checks are removed from examples. - The build stamp has been removed as it was only meant for Charts development purposes and it's no longer needed. Also development build related debug prints are removed as __DATE__ can't be used for all OS thus it doesn't make much sense. - Documentation structure has been updated based on the new module structure. The raw HTML files have been removed. Demos are combined to examples. - Unnecessary .qdocinc files are no longer needed. The content is moved to the corresponding .cpp files. - The Charts widget designer plugin is updated according to the module change. - The test cases updated according to the project structure change. Tests are added also for version 2.0. - cmake modules generation is not needed with Qt 5.4 and Qt Charts so it's disabled. - The new module name and version are updated to the plugin.qmltypes file. Task-number: QTRD-2844, QTRD-3217, QTRD-3218, QTRD-3277, QTRD-3228, QTRD-2526, QTRD-3233, QTRD-3222 Change-Id: Ib7fb26057cde710ffaf6bc780c8bf52a16f45160 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
Diffstat (limited to 'examples/charts/qmlaxes')
-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
7 files changed, 341 insertions, 0 deletions
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>