summaryrefslogtreecommitdiffstats
path: root/examples/datavisualization
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-03-28 14:51:26 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-04-01 08:28:57 +0300
commitfe3c9ec0a9fb734e83eb70bc725c303a9d36cd6d (patch)
tree4996d94f8a7e4498fa8431c9dcc65526a99889bb /examples/datavisualization
parent25f48fc046bbce83abeeef0a6081de9f5efcd6d7 (diff)
Axis formatter customization example
Also refactored the formatter api somewhat: - Removed virtual from allowNegatives and allowZero and added a setter function for those. This will make it cleaner if we need to add similar properties to the axis formatter in the future, as no new virtual methods can be added without breaking BC. - Changed the labelValues array to labelStrings list, as it makes more sense to directly format the strings in recalculate. Change-Id: I3ea005afa984bb756845ca356b999762e0807415 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples/datavisualization')
-rw-r--r--examples/datavisualization/datavisualization.pro3
-rw-r--r--examples/datavisualization/qmlaxisformatter/customformatter.cpp154
-rw-r--r--examples/datavisualization/qmlaxisformatter/customformatter.h71
-rw-r--r--examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc114
-rw-r--r--examples/datavisualization/qmlaxisformatter/main.cpp57
-rw-r--r--examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/Data.qml50
-rw-r--r--examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/NewButton.qml52
-rw-r--r--examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/main.qml183
-rw-r--r--examples/datavisualization/qmlaxisformatter/qmlaxisformatter.pro16
-rw-r--r--examples/datavisualization/qmlaxisformatter/qmlaxisformatter.qrc7
-rw-r--r--examples/datavisualization/qmloscilloscope/datasource.h2
11 files changed, 706 insertions, 3 deletions
diff --git a/examples/datavisualization/datavisualization.pro b/examples/datavisualization/datavisualization.pro
index 4330ef4c..ebb99e93 100644
--- a/examples/datavisualization/datavisualization.pro
+++ b/examples/datavisualization/datavisualization.pro
@@ -6,7 +6,8 @@ SUBDIRS += qmlbars \
qmllegend \
qmlmultigraph \
qmloscilloscope \
- qmlsurfacelayers
+ qmlsurfacelayers \
+ qmlaxisformatter
!android:!ios {
SUBDIRS += bars \
diff --git a/examples/datavisualization/qmlaxisformatter/customformatter.cpp b/examples/datavisualization/qmlaxisformatter/customformatter.cpp
new file mode 100644
index 00000000..eeea0451
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/customformatter.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** 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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+#include "customformatter.h"
+#include <QtDataVisualization/QValue3DAxis>
+#include <QtQml/QQmlExtensionPlugin>
+#include <QtCore/QDebug>
+
+using namespace QtDataVisualization;
+
+static const qreal oneDayMs = 60.0 * 60.0 * 24.0 * 1000.0;
+
+CustomFormatter::CustomFormatter(QObject *parent) :
+ QValue3DAxisFormatter(parent)
+{
+}
+
+CustomFormatter::~CustomFormatter()
+{
+}
+
+//! [1]
+QValue3DAxisFormatter *CustomFormatter::createNewInstance() const
+{
+ return new CustomFormatter();
+}
+
+void CustomFormatter::populateCopy(QValue3DAxisFormatter &copy) const
+{
+ QValue3DAxisFormatter::populateCopy(copy);
+
+ CustomFormatter *customFormatter = static_cast<CustomFormatter *>(&copy);
+ customFormatter->m_originDate = m_originDate;
+ customFormatter->m_selectionFormat = m_selectionFormat;
+}
+//! [1]
+
+//! [2]
+void CustomFormatter::recalculate()
+{
+ // We want our axis to always have gridlines at date breaks
+
+ // Convert range into QDateTimes
+ QDateTime minTime = valueToDateTime(qreal(axis()->min()));
+ QDateTime maxTime = valueToDateTime(qreal(axis()->max()));
+
+ // Find out the grid counts
+ QTime midnight(0, 0);
+ QDateTime minFullDate(minTime.date(), midnight);
+ int gridCount = 0;
+ if (minFullDate != minTime)
+ minFullDate = minFullDate.addDays(1);
+ QDateTime maxFullDate(maxTime.date(), midnight);
+
+ gridCount += minFullDate.daysTo(maxFullDate) + 1;
+ int subGridCount = axis()->subSegmentCount() - 1;
+
+ // Reserve space for position arrays and label strings
+ gridPositions().resize(gridCount);
+ subGridPositions().resize((gridCount + 1) * subGridCount);
+ labelPositions().resize(gridCount);
+ labelStrings().reserve(gridCount);
+
+ // Calculate positions and format labels
+ qint64 startMs = minTime.toMSecsSinceEpoch();
+ qint64 endMs = maxTime.toMSecsSinceEpoch();
+ qreal dateNormalizer = endMs - startMs;
+ qreal firstLineOffset = (minFullDate.toMSecsSinceEpoch() - startMs) / dateNormalizer;
+ qreal segmentStep = oneDayMs / dateNormalizer;
+ qreal subSegmentStep = 0;
+ if (subGridCount > 0)
+ subSegmentStep = segmentStep / qreal(subGridCount + 1);
+
+ for (int i = 0; i < gridCount; i++) {
+ qreal gridValue = firstLineOffset + (segmentStep * qreal(i));
+ gridPositions()[i] = float(gridValue);
+ labelPositions()[i] = float(gridValue);
+ labelStrings() << minFullDate.addDays(i).toString(axis()->labelFormat());
+ }
+
+ for (int i = 0; i <= gridCount; i++) {
+ if (subGridPositions().size()) {
+ for (int j = 0; j < subGridCount; j++) {
+ float position;
+ if (i)
+ position = gridPositions().at(i - 1) + subSegmentStep * (j + 1);
+ else
+ position = gridPositions().at(0) - segmentStep + subSegmentStep * (j + 1);
+ if (position > 1.0f || position < 0.0f)
+ position = gridPositions().at(0);
+ subGridPositions()[i * subGridCount + j] = position;
+ }
+ }
+ }
+}
+//! [2]
+
+//! [3]
+QString CustomFormatter::stringForValue(qreal value, const QString &format) const
+{
+ Q_UNUSED(format)
+
+ return valueToDateTime(value).toString(m_selectionFormat);
+}
+//! [3]
+
+QDate CustomFormatter::originDate() const
+{
+ return m_originDate;
+}
+
+QString CustomFormatter::selectionFormat() const
+{
+ return m_selectionFormat;
+}
+
+void CustomFormatter::setOriginDate(const QDate &date)
+{
+ if (m_originDate != date) {
+ m_originDate = date;
+ markDirty(true);
+ emit originDateChanged(date);
+ }
+}
+
+void CustomFormatter::setSelectionFormat(const QString &format)
+{
+ if (m_selectionFormat != format) {
+ m_selectionFormat = format;
+ emit selectionFormatChanged(format);
+ }
+}
+
+//! [0]
+QDateTime CustomFormatter::valueToDateTime(qreal value) const
+{
+ return QDateTime(m_originDate).addMSecs(qint64(oneDayMs * value));
+}
+//! [0]
diff --git a/examples/datavisualization/qmlaxisformatter/customformatter.h b/examples/datavisualization/qmlaxisformatter/customformatter.h
new file mode 100644
index 00000000..d439e56a
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/customformatter.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+#ifndef CUSTOMFORMATTER_H
+#define CUSTOMFORMATTER_H
+
+#include <QtDataVisualization/QValue3DAxisFormatter>
+#include <QtCore/QDateTime>
+#include <QtCore/QVector>
+
+using namespace QtDataVisualization;
+
+//! [2]
+class CustomFormatter : public QValue3DAxisFormatter
+{
+ //! [2]
+ Q_OBJECT
+
+ //! [1]
+ Q_PROPERTY(QDate originDate READ originDate WRITE setOriginDate NOTIFY originDateChanged)
+ //! [1]
+ //! [3]
+ Q_PROPERTY(QString selectionFormat READ selectionFormat WRITE setSelectionFormat NOTIFY selectionFormatChanged)
+ //! [3]
+public:
+ explicit CustomFormatter(QObject *parent = 0);
+ virtual ~CustomFormatter();
+
+ //! [0]
+ virtual QValue3DAxisFormatter *createNewInstance() const;
+ virtual void populateCopy(QValue3DAxisFormatter &copy) const;
+ virtual void recalculate();
+ virtual QString stringForValue(qreal value, const QString &format) const;
+ //! [0]
+
+ QDate originDate() const;
+ QString selectionFormat() const;
+
+public slots:
+ void setOriginDate(const QDate &date);
+ void setSelectionFormat(const QString &format);
+
+signals:
+ void originDateChanged(const QDate &date);
+ void selectionFormatChanged(const QString &format);
+
+private:
+ Q_DISABLE_COPY(CustomFormatter)
+
+ QDateTime valueToDateTime(qreal value) const;
+
+ QDate m_originDate;
+ QString m_selectionFormat;
+};
+
+#endif
diff --git a/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc b/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc
new file mode 100644
index 00000000..b990c490
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** 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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+/*!
+ \example qmlaxisformatter
+ \title Qt Quick 2 Axis Formatter Example
+ \ingroup qtdatavisualization_examples
+ \brief Example of a hybrid C++ and QML application demonstrating different axis formatters.
+
+ The Qt Quick axis formatter example shows how to use predefined axis formatters and how to
+ create a custom one.
+
+ \image qmlaxisformatter-example.png
+
+ The interesting thing about this example is axis formatters, so we'll concentrate on
+ that and skip explaining the basic functionality - for
+ more detailed QML example documentation, see \l{Qt Quick 2 Scatter Example}.
+
+ \section1 Custom axis formatter
+
+ Customizing axis formatters requires subclassing the QValue3DAxisFormatter, which cannot be
+ done in QML code alone. In this example we want an axis that interprets the float values as
+ a timestamp and shows the date in the axis labels. To achieve this, we introduce a new class
+ called \c CustomFormatter, which subclasses the QValue3DAxisFormatter:
+
+ \snippet qmlaxisformatter/customformatter.h 2
+ \dots 0
+
+ Since float values of a QScatter3DSeries cannot be directly cast into QDateTime values due to
+ difference in data width, we need some sort of mapping between the two. We chose to do the
+ mapping by specifying an origin date for the formatter and interpreting the float values
+ from the QScatter3DSeries as date offsets to that origin value. The origin date is given as
+ a property:
+
+ \snippet qmlaxisformatter/customformatter.h 1
+
+ The mapping from value to QDateTime is done using \c valueToDateTime() method:
+
+ \snippet qmlaxisformatter/customformatter.cpp 0
+
+ To function as an axis formatter, our \c CustomFormatter needs to reimplement some virtual
+ methods:
+
+ \snippet qmlaxisformatter/customformatter.h 0
+
+ The first two are simple, we just create a new instance of \c CustomFormatter and copy the
+ necessary data over to it. These two methods are used to create and update a cache of formatter for
+ rendering purposes. It is important to remember to call the superclass implementation
+ of \c populateCopy():
+
+ \snippet qmlaxisformatter/customformatter.cpp 1
+
+ Bulk of the work done by \c CustomFormatter is done in the \c recalculate() method, where
+ our formatter calculates the grid, subgrid, and label positions, as well as formats the label
+ strings.
+ In our custom formatter we ignore the segment count of the axis and draw a grid line always at
+ midnight. Subsegment count and label positioning is handled normally:
+
+ \snippet qmlaxisformatter/customformatter.cpp 2
+
+ The axis labels are formatted to show only the date, but for selection label we want little more
+ resolution for the timestamp, so we specify another property for our custom formatter to allow
+ user to customize it:
+
+ \snippet qmlaxisformatter/customformatter.h 3
+
+ This selection format property is used in the reimplemented \c stringToValue method, where we
+ ignore the submitted format and substitute the custom selection format for it:
+
+ \snippet qmlaxisformatter/customformatter.cpp 3
+
+ To expose our new custom formatter to the QML, we must declare and register it:
+
+ \snippet qmlaxisformatter/main.cpp 0
+ \dots 0
+ \snippet qmlaxisformatter/main.cpp 1
+
+ \section1 QML
+
+ In the QML codes, we define a different axis for each dimension:
+
+ \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 3
+
+ Z-axis is just a regular ValueAxis3D:
+
+ \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 0
+
+ For the Y-axis we define a logarithmic axis. ValueAxis3D can be made to show logarithmic scale
+ by specifying LogValueAxis3DFormatter for \c formatter property of the axis:
+
+ \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 2
+
+ And finally, for the X-axis we use our new \c CustomFormatter:
+
+ \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 1
+
+ Rest of the application consists of fairly self-explanatory logic for modifying the axes and
+ showing the graph.
+*/
diff --git a/examples/datavisualization/qmlaxisformatter/main.cpp b/examples/datavisualization/qmlaxisformatter/main.cpp
new file mode 100644
index 00000000..05ed7b37
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/main.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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+#include "customformatter.h"
+
+#include <QtGui/QGuiApplication>
+#include <QtQuick/QQuickView>
+#include <QtQml>
+
+//! [0]
+Q_DECLARE_METATYPE(CustomFormatter *)
+//! [0]
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ //! [1]
+ qmlRegisterType<CustomFormatter>("CustomFormatter", 1, 0, "CustomFormatter");
+ //! [1]
+
+ 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("Axis formatter example"));
+
+ viewer.setSource(QUrl("qrc:/qml/qmlaxisformatter/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/Data.qml b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/Data.qml
new file mode 100644
index 00000000..e692c090
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/Data.qml
@@ -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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ property alias model: dataModel
+
+ ListModel {
+ id: dataModel
+ ListElement{ xPos: 2.456103; yPos: 1.0; zPos: 5.0 }
+ ListElement{ xPos: 5.687549; yPos: 3.0; zPos: 2.5 }
+ ListElement{ xPos: 2.357458; yPos: 4.1; zPos: 1.0 }
+ ListElement{ xPos: 4.567458; yPos: 4.75; zPos: 3.9 }
+ ListElement{ xPos: 6.885439; yPos: 4.9; zPos: 7.2 }
+ ListElement{ xPos: 2.366769; yPos: 13.42; zPos: 3.5 }
+ ListElement{ xPos: 7.546457; yPos: 233.1; zPos: 6.9 }
+ ListElement{ xPos: 2.475867; yPos: 32.91; zPos: 4.1 }
+ ListElement{ xPos: 8.456546; yPos: 153.68; zPos: 9.52 }
+ ListElement{ xPos: 3.456348; yPos: 52.96; zPos: 1.6 }
+ ListElement{ xPos: 1.536446; yPos: 32.4; zPos: 2.92 }
+ ListElement{ xPos: 8.456666; yPos: 114.74; zPos: 8.18 }
+ ListElement{ xPos: 5.468486; yPos: 83.1; zPos: 3.8 }
+ ListElement{ xPos: 6.546586 ; yPos: 63.66; zPos: 3.58 }
+ ListElement{ xPos: 8.567516 ; yPos: 1.82; zPos: 4.64 }
+ ListElement{ xPos: 7.678984 ; yPos: 213.18; zPos: 7.22 }
+ ListElement{ xPos: 7.457569 ; yPos: 63.06; zPos: 4.3 }
+ ListElement{ xPos: 8.456755 ; yPos: 122.64; zPos: 6.44 }
+ ListElement{ xPos: 6.234536 ; yPos: 63.96; zPos: 4.38 }
+ ListElement{ xPos: 9.456718 ; yPos: 243.32; zPos: 4.04 }
+ ListElement{ xPos: 10.789889 ; yPos: 43.4; zPos: 2.78 }
+ ListElement{ xPos: 11.346554 ; yPos: 345.12; zPos: 3.1 }
+ ListElement{ xPos: 12.023454 ; yPos: 500.0; zPos: 3.68 }
+ }
+}
diff --git a/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/NewButton.qml b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/NewButton.qml
new file mode 100644
index 00000000..e4fb99d2
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/NewButton.qml
@@ -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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ id: newbutton
+
+ property alias text: buttonText.text
+
+ 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: buttonText.text
+ clip: true
+ wrapMode: Text.WordWrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ }
+ }
+ }
+ onClicked: newbutton.clicked()
+ }
+}
diff --git a/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/main.qml b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/main.qml
new file mode 100644
index 00000000..7aba08c6
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/qml/qmlaxisformatter/main.qml
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** 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 QtDataVisualization module.
+**
+** 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
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Layouts 1.0
+import QtDataVisualization 1.1
+import CustomFormatter 1.0
+import "."
+
+Rectangle {
+ id: mainView
+ width: 1280
+ height: 1024
+
+ Data {
+ id: seriesData
+ }
+
+ Theme3D {
+ id: themeIsabelle
+ type: Theme3D.ThemePrimaryColors
+ font.family: "Lucida Handwriting"
+ font.pointSize: 40
+ }
+
+ //! [1]
+ ValueAxis3D {
+ id: dateAxis
+ formatter: CustomFormatter {
+ originDate: "2014-01-01"
+ selectionFormat: "yyyy-MM-dd HH:mm:ss"
+ }
+ subSegmentCount: 2
+ labelFormat: "yyyy-MM-dd"
+ min: 0
+ max: 14
+ }
+ //! [1]
+
+ //! [2]
+ ValueAxis3D {
+ id: logAxis
+ formatter: LogValueAxis3DFormatter {
+ id: logAxisFormatter
+ base: 10
+ autoSubGrid: true
+ showEdgeLabels: true
+ }
+ labelFormat: "%.2f"
+ }
+ //! [2]
+
+ ValueAxis3D {
+ id: linearAxis
+ labelFormat: "%.2f"
+ min: 0
+ max: 500
+ }
+
+ //! [0]
+ ValueAxis3D {
+ id: valueAxis
+ segmentCount: 5
+ subSegmentCount: 2
+ labelFormat: "%.2f"
+ min: 0
+ max: 10
+ }
+ //! [0]
+
+ Item {
+ id: dataView
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: parent.height - buttonLayout.height
+
+ Scatter3D {
+ id: scatterGraph
+ width: dataView.width
+ height: dataView.height
+ theme: themeIsabelle
+ shadowQuality: AbstractGraph3D.ShadowQualitySoftLow
+ scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricRight
+ //! [3]
+ axisZ: valueAxis
+ axisY: logAxis
+ axisX: dateAxis
+ //! [3]
+
+ Scatter3DSeries {
+ id: scatterSeries
+ itemLabelFormat: "@xLabel - (@yLabel, @zLabel)"
+ meshSmooth: true
+ ItemModelScatterDataProxy {
+ itemModel: seriesData.model
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
+ }
+ }
+ }
+ }
+
+ RowLayout {
+ id: buttonLayout
+ Layout.minimumHeight: exitButton.height
+ width: parent.width
+ anchors.left: parent.left
+ spacing: 0
+
+ NewButton {
+ id: yAxisBaseChange
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ state: "enabled"
+ onClicked: {
+ if (logAxisFormatter.base === 10)
+ logAxisFormatter.base = 0
+ else if (logAxisFormatter.base === 2)
+ logAxisFormatter.base = 10
+ else
+ logAxisFormatter.base = 2
+ }
+ states: [
+ State {
+ name: "enabled"
+ PropertyChanges {
+ target: yAxisBaseChange
+ text: "Y-axis log base: " + logAxisFormatter.base
+ enabled: true
+ }
+ },
+ State {
+ name: "disabled"
+ PropertyChanges {
+ target: yAxisBaseChange
+ text: "Y-axis linear"
+ enabled: false
+ }
+ }
+ ]
+ }
+
+ NewButton {
+ id: yAxisToggle
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Toggle Y-axis"
+ onClicked: {
+ if (scatterGraph.axisY === linearAxis) {
+ scatterGraph.axisY = logAxis
+ yAxisBaseChange.state = "enabled"
+ } else {
+ scatterGraph.axisY = linearAxis
+ yAxisBaseChange.state = "disabled"
+ }
+ }
+ }
+
+ NewButton {
+ id: exitButton
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ text: "Quit"
+ onClicked: Qt.quit(0);
+ }
+ }
+}
diff --git a/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.pro b/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.pro
new file mode 100644
index 00000000..0f3b2f80
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.pro
@@ -0,0 +1,16 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += datavisualization
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp \
+ customformatter.cpp
+HEADERS += customformatter.h
+
+RESOURCES += qmlaxisformatter.qrc
+
+OTHER_FILES += doc/src/* \
+ doc/images/* \
+ qml/qmlaxisformatter/*
diff --git a/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.qrc b/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.qrc
new file mode 100644
index 00000000..0cd9e927
--- /dev/null
+++ b/examples/datavisualization/qmlaxisformatter/qmlaxisformatter.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/qmlaxisformatter/main.qml</file>
+ <file>qml/qmlaxisformatter/NewButton.qml</file>
+ <file>qml/qmlaxisformatter/Data.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/datavisualization/qmloscilloscope/datasource.h b/examples/datavisualization/qmloscilloscope/datasource.h
index ef2f7acb..4f210269 100644
--- a/examples/datavisualization/qmloscilloscope/datasource.h
+++ b/examples/datavisualization/qmloscilloscope/datasource.h
@@ -22,8 +22,6 @@
#include <QtDataVisualization/QSurface3DSeries>
#include <QtDataVisualization/QValue3DAxis>
-class QQuickView;
-
using namespace QtDataVisualization;
class DataSource : public QObject