From a62b3bfbefaac8b82db669cdfcdd00c3bfade915 2012-09-03 12:31:44 From: Tero Ahola Date: 2012-09-03 12:31:44 Subject: [PATCH] Fixed a bug in setting axes dynamically via QML API --- diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index b5aaa73..dce629f 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -255,7 +255,7 @@ void DeclarativeChart::componentComplete() QAbstractSeries *series = qobject_cast(child); m_chart->addSeries(series); - // Set optional user defined axes and connect axis related signals + // Set optional user defined axes for the series and connect axis related signals if (qobject_cast(child)) { DeclarativeLineSeries *s = qobject_cast(child); connect(s, SIGNAL(axisXChanged(QAbstractAxis*)), this, SLOT(handleAxisXSet(QAbstractAxis*))); @@ -317,31 +317,32 @@ void DeclarativeChart::componentComplete() setAxisX(s->axisX(), s); setAxisY(s->axisY(), s); } - - // Create the missing axes for the series that cannot be painted without axes - createDefaultAxes(series); - } else if(qobject_cast(child)) { - // Do nothing, axes are set for the chart in the context of series } } + // Create the missing axes for the series that cannot be painted without axes + foreach (QAbstractSeries *chartSeries, m_chart->series()) + createDefaultAxes(chartSeries); + QDeclarativeItem::componentComplete(); } void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) { // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; - if (axis && qobject_cast(sender())) { - m_chart->setAxisX(axis, qobject_cast(sender())); - } + if (axis && qobject_cast(sender())) + m_chart->setAxisX(axis, qobject_cast(sender())); + else + qWarning() << "Trying to set axisX to null."; } void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) { // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; - if (axis && qobject_cast(sender())) { - m_chart->setAxisY(axis, qobject_cast(sender())); - } + if (axis && qobject_cast(sender())) + m_chart->setAxisY(axis, qobject_cast(sender())); + else + qWarning() << "Trying to set axisY to null."; } void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml new file mode 100644 index 0000000..2cebc7b --- /dev/null +++ b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial 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 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + id: chartView + title: "chart axes" + + // TODO: Do we need a property for orientation or properties "axisX" and "axisY" on ChartView + // to make an axis the default axis for all series with no other axes defined...? +// ValueAxis { +// orientation: ValueAxis.AxisX +// min: 0 +// max: 10 +// } +// axisX: ValueAxis { +// min: 0 +// max: 10 +// } + // ...Now that we don't have this implementation, the following axes won't have any affect: + ValueAxis { + min: 0 + max: 10 + } + ValueAxis { + min: 0 + max: 5 + } + + LineSeries { + name: "line series" + XYPoint { x: 0; y: 0 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } + + ScatterSeries { + name: "scatter series" + XYPoint { x: 0; y: 0 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } + +// Component.onCompleted: { +// // You can also set the axes dynamically +// chartView.setAxisX(axisX, scatter); +// } +} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart2.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml similarity index 67% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart2.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml index 29250a6..e4945d2 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart2.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml @@ -23,49 +23,36 @@ import QtCommercial.Chart 1.1 ChartView { id: chartView - title: "user defined axes" + title: "chart axes reverted" ValueAxis { - id: axisX min: 0 max: 10 - // TODO: property to fix orientation to "X" to make this the X default axis for all series - // that don't have user defined X axis } - ValueAxis { - id: axisY min: 0 max: 5 - // TODO: property to fix orientation to "Y" to make this the Y default axis for all series - // that don't have user defined Y axis - } - - LineSeries { - name: "line series" - 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 } } ScatterSeries { name: "scatter series" - id: scatter 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } - Component.onCompleted: { - // You can also set the axes dynamically - chartView.setAxisX(axisX, scatter); + LineSeries { + name: "line series" + XYPoint { x: 0; y: 0 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart3.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml similarity index 76% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart3.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml index 129b64d..f13a814 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart3.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml @@ -33,16 +33,16 @@ ChartView { onTriggered: { switch (index) { case 0: - chartView.axisX(lineSeries).max = 5; - chartView.axisY(lineSeries).max = 5; + chartView.axisX(lineSeries).max = 6; + chartView.axisY(lineSeries).max = 6; break; case 1: chartView.axisX(scatterSeries).max = 10; chartView.axisY(scatterSeries).max = 10; break; default: - chartView.axisX().max = 15; - chartView.axisY().max = 15; + chartView.axisX().max = 4; + chartView.axisY().max = 4; } index = (index + 1) % 3; } @@ -52,23 +52,23 @@ ChartView { id: lineSeries name: "line series" 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } ScatterSeries { id: scatterSeries name: "scatter series" 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart5.qml b/tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml similarity index 76% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart5.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml index d3b28db..67ae2b5 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart5.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml @@ -23,7 +23,7 @@ import QtCommercial.Chart 1.1 ChartView { id: chartView - title: "dynamically created series" + title: "creating dyn. new series" property int index: 0 Timer { @@ -33,16 +33,16 @@ ChartView { onTriggered: { switch (index) { case 0: - while (chartView.count) + while (chartView.count) { + console.log("Destroying series. Count: " + chartView.count); chartView.series(0).destroy(); + } var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); line.append(0, 0); - line.append(1.1, 2.1); - line.append(1.9, 3.3); - line.append(2.1, 2.1); - line.append(2.9, 4.9); - line.append(3.4, 3.0); - line.append(4.1, 3.3); + line.append(1, 1); + line.append(2, 2); + line.append(3, 3); + line.append(4, 4); break; case 1: chartView.axisX().min = 0; @@ -53,12 +53,14 @@ ChartView { default: var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); scatter.append(0, 0); - scatter.append(1.1, 2.1); - scatter.append(1.9, 3.3); - scatter.append(2.1, 2.1); - scatter.append(2.9, 4.9); - scatter.append(3.4, 3.0); - scatter.append(4.1, 3.3); + scatter.append(0.5, 1); + scatter.append(1, 2); + scatter.append(1.5, 3); + scatter.append(2, 4); + scatter.append(1, 1); + scatter.append(2, 2); + scatter.append(3, 3); + scatter.append(4, 4); } index = (index + 1) % 3; } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml new file mode 100644 index 0000000..07f887e --- /dev/null +++ b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial 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 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + title: "default + user defined" + + ValueAxis { + id: axisX + min: 0 + max: 6 + } + + ValueAxis { + id: axisY + min: 0 + max: 6 + } + + LineSeries { + name: "line series 1" + XYPoint { x: 0; y: 0 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } + + ScatterSeries { + name: "scatter series" + axisX: axisX + axisY: axisY + XYPoint { x: 0; y: 0 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } + + LineSeries { + name: "line series 2" + XYPoint { x: 0; y: 0 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + } +} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart0.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml similarity index 73% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart0.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml index 932b60a..003f7de 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart0.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml @@ -28,22 +28,22 @@ ChartView { LineSeries { name: "line series" 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } ScatterSeries { name: "scatter series" 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart7.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml similarity index 73% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart7.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml index 2e423ea..07c1680 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart7.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml @@ -23,21 +23,27 @@ import QtCommercial.Chart 1.1 ChartView { id: chartView - title: "axis scale; different series" + title: "default axes" - LineSeries { - name: "line series" + ScatterSeries { + name: "scatter series" 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: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } - ScatterSeries { - name: "scatter series" - 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 } + LineSeries { + name: "line series" + XYPoint { x: 0; y: 0 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart8.qml b/tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml similarity index 76% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart8.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml index 0497cf8..727282b 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart8.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml @@ -35,22 +35,22 @@ ChartView { LineSeries { name: "line series" 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } ScatterSeries { name: "scatter series" 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart4.qml b/tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml similarity index 76% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart4.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml index f39eb42..cb32a7a 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart4.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml @@ -33,20 +33,20 @@ ChartView { onTriggered: { switch (index) { case 0: - lineAxisX.max = 5; - lineAxisY.max = 5; + lineAxisX.max = 6; + lineAxisY.max = 6; scatterAxisX.max = 10; scatterAxisY.max = 10; break; case 1: lineAxisX.max = 10; lineAxisY.max = 10; - scatterAxisX.max = 5; - scatterAxisY.max = 5; + scatterAxisX.max = 6; + scatterAxisY.max = 6; break; default: - chartView.axisX().max = 2; - chartView.axisY().max = 2; + chartView.axisX().max = 4; + chartView.axisY().max = 4; } index = (index + 1) % 3; } @@ -57,14 +57,11 @@ ChartView { name: "line series" axisX: ValueAxis { id: lineAxisX } axisY: ValueAxis { id: lineAxisY } - 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } ScatterSeries { @@ -72,13 +69,14 @@ ChartView { name: "scatter series" axisX: ValueAxis { id: scatterAxisX } axisY: ValueAxis { id: scatterAxisY } - 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart6.qml b/tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml similarity index 81% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart6.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml index 8dcf0b9..9fd6510 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart6.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml @@ -30,10 +30,13 @@ ChartView { repeat: true running: true onTriggered: { + //console.log("current axisX: " + lineSeries.axisX + " 1: " + valueAxis1 + " 2: " +valueAxis2); + + // Note: an axis is destroyed if it is not used anymore if (lineSeries.axisX == valueAxis1) lineSeries.axisX = valueAxis2; - else - lineSeries.axisX = valueAxis1; + else if (lineSeries.axisX == valueAxis2) + lineSeries.axisX = valueAxis3; } } @@ -49,16 +52,20 @@ ChartView { max: 6 } + ValueAxis { + id: valueAxis3 + min: 2 + max: 7 + } + LineSeries { id: lineSeries name: "line series" axisX: valueAxis1 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Chart1.qml b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml similarity index 75% rename from tests/qmlchartaxis/qml/qmlchartaxis/Chart1.qml rename to tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml index 31679ca..c08dd57 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Chart1.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml @@ -22,12 +22,12 @@ import QtQuick 1.0 import QtCommercial.Chart 1.1 ChartView { - title: "user defined axes" + title: "user defined" ValueAxis { id: axisX min: 0 - max: 10 + max: 6 } ValueAxis { @@ -41,12 +41,10 @@ ChartView { axisX: axisX axisY: axisY 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 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } ScatterSeries { @@ -54,11 +52,13 @@ ChartView { axisX: axisX axisY: axisY 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 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } } } diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml new file mode 100644 index 0000000..bb62adc --- /dev/null +++ b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial 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 1.0 +import QtCommercial.Chart 1.1 + +ChartView { + title: "user defined reverted" + + ValueAxis { + id: axisX + min: 0 + max: 6 + } + + ValueAxis { + id: axisY + min: 0 + max: 6 + } + + ScatterSeries { + name: "scatter series" + axisX: axisX + axisY: axisY + XYPoint { x: 0; y: 0 } + XYPoint { x: 0.5; y: 1 } + XYPoint { x: 1; y: 2 } + XYPoint { x: 1.5; y: 3 } + XYPoint { x: 2; y: 4 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } + + LineSeries { + name: "line series" + axisX: axisX + axisY: axisY + XYPoint { x: 0; y: 0 } + XYPoint { x: 1; y: 1 } + XYPoint { x: 2; y: 2 } + XYPoint { x: 3; y: 3 } + XYPoint { x: 4; y: 4 } + } +} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/main.qml b/tests/qmlchartaxis/qml/qmlchartaxis/main.qml index 311dc18..c013b33 100644 --- a/tests/qmlchartaxis/qml/qmlchartaxis/main.qml +++ b/tests/qmlchartaxis/qml/qmlchartaxis/main.qml @@ -24,7 +24,7 @@ Rectangle { id: main width: 400 height: 300 - property int viewNumber: 0 + property string viewName: "DefaultAxes" Row { anchors.fill: parent @@ -34,7 +34,7 @@ Rectangle { id: chartLoader width: parent.width - buttonColumn.width height: parent.height - source: "Chart" + viewNumber + ".qml" + source: viewName + ".qml" } Column { @@ -44,40 +44,52 @@ Rectangle { spacing: 5 Button { - text: "Default" - onClicked: viewNumber = 0; + text: "Default axes" + onClicked: viewName = "DefaultAxes"; + } + Button { + text: "Default axes reverted" + onClicked: viewName = "DefaultAxesRevert"; } Button { text: "User defined" - onClicked: viewNumber = 1; + onClicked: viewName = "UserDefined"; + } + Button { + text: "User defined reverted" + onClicked: viewName = "UserDefinedRevert"; } Button { text: "Chart axes" - onClicked: viewNumber = 2; + onClicked: viewName = "ChartAxes"; + } + Button { + text: "Chart axes reverted" + onClicked: viewName = "ChartAxesRevert"; } Button { text: "Configuring dynamically" - onClicked: viewNumber = 3; + onClicked: viewName = "ConfiguringDynamically"; } Button { text: "Series specific dynamic" - onClicked: viewNumber = 4; + onClicked: viewName = "SeriesSpecificDynamic"; } Button { text: "Creating dynamically" - onClicked: viewNumber = 5; + onClicked: viewName = "CreatingDynamically"; } Button { text: "Switching dynamically" - onClicked: viewNumber = 6; + onClicked: viewName = "SwitchingDynamically"; } Button { - text: "Axis scale" - onClicked: viewNumber = 7; + text: "Default + User defined" + onClicked: viewName = "DefaultAndUserDefined"; } Button { text: "Legacy" - onClicked: viewNumber = 8; + onClicked: viewName = "Legacy"; } } } diff --git a/tests/qmlchartaxis/resources.qrc b/tests/qmlchartaxis/resources.qrc index 82a79ac..2f9f4b6 100644 --- a/tests/qmlchartaxis/resources.qrc +++ b/tests/qmlchartaxis/resources.qrc @@ -2,14 +2,17 @@ qml/qmlchartaxis/main.qml qml/qmlchartaxis/Button.qml - qml/qmlchartaxis/Chart0.qml - qml/qmlchartaxis/Chart1.qml - qml/qmlchartaxis/Chart2.qml - qml/qmlchartaxis/Chart3.qml - qml/qmlchartaxis/Chart4.qml - qml/qmlchartaxis/Chart5.qml - qml/qmlchartaxis/Chart6.qml - qml/qmlchartaxis/Chart7.qml - qml/qmlchartaxis/Chart8.qml + qml/qmlchartaxis/DefaultAxes.qml + qml/qmlchartaxis/DefaultAxesRevert.qml + qml/qmlchartaxis/UserDefined.qml + qml/qmlchartaxis/UserDefinedRevert.qml + qml/qmlchartaxis/ChartAxes.qml + qml/qmlchartaxis/ChartAxesRevert.qml + qml/qmlchartaxis/ConfiguringDynamically.qml + qml/qmlchartaxis/SeriesSpecificDynamic.qml + qml/qmlchartaxis/CreatingDynamically.qml + qml/qmlchartaxis/SwitchingDynamically.qml + qml/qmlchartaxis/DefaultAndUserDefined.qml + qml/qmlchartaxis/Legacy.qml