diff --git a/examples/tablemodelchart/tablewidget.cpp b/examples/tablemodelchart/tablewidget.cpp index bfb998f..7675532 100644 --- a/examples/tablemodelchart/tablewidget.cpp +++ b/examples/tablemodelchart/tablewidget.cpp @@ -261,7 +261,8 @@ void TableWidget::updateChartType(bool toggle) pieSeries->setModelMapping(0,0, Qt::Vertical); pieSeries->setLabelsVisible(true); pieSeries->setPieSize(0.4); - pieSeries->setPiePosition(0.2, 0.35); + pieSeries->setHorizontalPosition(0.2); + pieSeries->setVerticalPosition(0.35); m_chart->addSeries(pieSeries); seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); @@ -273,7 +274,8 @@ void TableWidget::updateChartType(bool toggle) pieSeries->setModelMapping(1,1, Qt::Vertical); pieSeries->setLabelsVisible(true); pieSeries->setPieSize(0.4); - pieSeries->setPiePosition(0.8, 0.35); + pieSeries->setHorizontalPosition(0.8); + pieSeries->setVerticalPosition(0.35); m_chart->addSeries(pieSeries); seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); m_model->addMapping(seriesColorHex, QRect(1, 0, 1, 1000)); @@ -284,7 +286,8 @@ void TableWidget::updateChartType(bool toggle) pieSeries->setModelMapping(2,2, Qt::Vertical); pieSeries->setLabelsVisible(true); pieSeries->setPieSize(0.4); - pieSeries->setPiePosition(0.5, 0.65); + pieSeries->setHorizontalPosition(0.5); + pieSeries->setVerticalPosition(0.65); m_chart->addSeries(pieSeries); seriesColorHex = "#" + QString::number(pieSeries->slices().at(pieSeries->slices().count()/2)->brush().color().rgb(), 16).right(6).toUpper(); m_model->addMapping(seriesColorHex, QRect(2, 0, 1, 1000)); diff --git a/test/qmlchart/qml/qmlchart/View1.qml b/test/qmlchart/qml/qmlchart/View1.qml new file mode 100644 index 0000000..0e66371 --- /dev/null +++ b/test/qmlchart/qml/qmlchart/View1.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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.0 + +Rectangle { + width: parent.width + height: parent.height + + // Another option for QML data api: +// ListModel { +// id: listModelForPie +// // PieDataElement +// ListElement { +// label: "Apple" +// value: 4.3 +// } +// ListElement { +// label: "Blackberry" +// value: 15.1 +// } +// } + + Component.onCompleted: { +// console.log("model:" + myModel.item(0)); +// myModel.insert(1, {"time":1.4; "speed":41.1 }); +// scatter.appendData(); +// chart1.theme = Chart.ThemeHighContrast; +// chart2.theme = Chart.ThemeHighContrast; + } + + Chart { + id: chart1 + anchors.fill: parent + theme: Chart.ChartThemeDark + + BarSeries { + barCategories: [ "2008", "2009", "2010", "2011", "2012" ] + // TBD: data + } + + PieSeries { + horizontalPosition: 0.2 + verticalPosition: 0.3 + size: 0.4 + endAngle: 0.52 * 360 // The share of "others" is 52% + slices: [ + 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 } + ] + } + } +} diff --git a/test/qmlchart/qml/qmlchart/View2.qml b/test/qmlchart/qml/qmlchart/View2.qml new file mode 100644 index 0000000..b380d34 --- /dev/null +++ b/test/qmlchart/qml/qmlchart/View2.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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.0 + +Rectangle { + anchors.fill: parent + + Chart { + anchors.fill: parent + theme: Chart.ChartThemeBrownSand + + LineSeries { + name: "Line" + points: [ + XyPoint { x: 0.0; y: 0.0 }, + XyPoint { x: 1.1; y: 2.1 }, + XyPoint { x: 2.9; y: 4.9 }, + XyPoint { x: 3.2; y: 3.0 } + ] + } + + SplineSeries { + name: "Spline" + points: [ + XyPoint { x: 0.0; y: 0.3 }, + XyPoint { x: 1.1; y: 3.2 }, + XyPoint { x: 2.17; y: 2.15 }, + XyPoint { x: 4.17; y: 3.15 } + ] + } + } +} diff --git a/test/qmlchart/qml/qmlchart/View3.qml b/test/qmlchart/qml/qmlchart/View3.qml new file mode 100644 index 0000000..0a2c884 --- /dev/null +++ b/test/qmlchart/qml/qmlchart/View3.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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.0 + +Rectangle { + anchors.fill: parent + + Chart { + anchors.fill: parent + theme: Chart.ChartThemeHighContrast + + AreaSeries { + name: "Area" + points: [ + XyPoint { x: 0.0; y: 1.1 }, + XyPoint { x: 2.5; y: 3.6 }, + XyPoint { x: 3.57; y: 2.55 } + ] + lowerPoints: [ + XyPoint { x: 0.0; y: 0.0 }, + XyPoint { x: 2.5; y: 0.0 }, + XyPoint { x: 3.57; y: 0.0 } + ] + } + + ScatterSeries { + name: "Scatter1" + points: [ + XyPoint { x: 1.5; y: 1.5 }, + XyPoint { x: 1.5; y: 1.6 }, + XyPoint { x: 1.57; y: 1.55 } + ] + } + ScatterSeries { + name: "Scatter2" + points: [ + XyPoint { x: 2.0; y: 2.0 }, + XyPoint { x: 2.0; y: 2.1 }, + XyPoint { x: 2.07; y: 2.05 } + ] + } + ScatterSeries { + name: "Scatter3" + points: [ + XyPoint { x: 2.6; y: 2.6 }, + XyPoint { x: 2.6; y: 2.7 }, + XyPoint { x: 2.67; y: 2.65 } + ] + } + } +} diff --git a/test/qmlchart/qml/qmlchart/loader.qml b/test/qmlchart/qml/qmlchart/loader.qml index 3011ee1..7668f0c 100644 --- a/test/qmlchart/qml/qmlchart/loader.qml +++ b/test/qmlchart/qml/qmlchart/loader.qml @@ -23,7 +23,7 @@ import QtQuick 1.0 Item { id: container width: 400 - height: 500 + height: 300 Component.onCompleted: { var co = Qt.createComponent("main.qml") if (co.status == Component.Ready) { diff --git a/test/qmlchart/qml/qmlchart/main.qml b/test/qmlchart/qml/qmlchart/main.qml index 030d695..38c2f97 100644 --- a/test/qmlchart/qml/qmlchart/main.qml +++ b/test/qmlchart/qml/qmlchart/main.qml @@ -24,124 +24,31 @@ import QtCommercial.Chart 1.0 Rectangle { width: parent.width height: parent.height - - // Another option for QML data api: -// ListModel { -// id: listModelForPie -// // PieDataElement -// ListElement { -// label: "Apple" -// value: 4.3 -// } -// ListElement { -// label: "Blackberry" -// value: 15.1 -// } -// } - - Component.onCompleted: { -// console.log("model:" + myModel.item(0)); -// myModel.insert(1, {"time":1.4; "speed":41.1 }); -// scatter.appendData(); -// chart1.theme = Chart.ThemeHighContrast; -// chart2.theme = Chart.ThemeHighContrast; - } - - - Chart { - id: chart1 - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: parent.height / 2 - theme: Chart.ChartThemeDark - - BarSeries { - barCategories: [ "2008", "2009", "2010", "2011", "2012" ] - // TBD: data - } - - PieSeries { - horizontalPosition: 0.2 - verticalPosition: 0.3 - size: 0.4 - endAngle: 0.52 * 360 // The share of "others" is 52% - slices: [ - 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 } - ] + property int __viewNumber: 0 + + Timer { + id: timer + running: true + repeat: true + interval: 5000 + triggeredOnStart: true + onTriggered: { + loader.source = "View" + (__viewNumber % 3 + 1) + ".qml"; + __viewNumber++; } } + Loader { + id: loader + anchors.fill: parent + } - Chart { - id: chart2 - anchors.top: chart1.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - theme: Chart.ChartThemeBrownSand - - LineSeries { - name: "Line" - points: [ - XyPoint { x: 0.0; y: 0.0 }, - XyPoint { x: 1.1; y: 2.1 }, - XyPoint { x: 2.9; y: 4.9 }, - XyPoint { x: 3.2; y: 3.0 } - ] - } - - SplineSeries { - name: "Spline" - points: [ - XyPoint { x: 0.0; y: 0.3 }, - XyPoint { x: 1.1; y: 3.2 }, - XyPoint { x: 2.17; y: 2.15 }, - XyPoint { x: 4.17; y: 3.15 } - ] - } - - AreaSeries { - name: "Area" - points: [ - XyPoint { x: 0.0; y: 1.1 }, - XyPoint { x: 2.5; y: 3.6 }, - XyPoint { x: 3.57; y: 2.55 } - ] - lowerPoints: [ - XyPoint { x: 0.0; y: 0.0 }, - XyPoint { x: 2.5; y: 0.0 }, - XyPoint { x: 3.57; y: 0.0 } - ] - } - - ScatterSeries { - name: "Scatter1" - points: [ - XyPoint { x: 1.5; y: 1.5 }, - XyPoint { x: 1.5; y: 1.6 }, - XyPoint { x: 1.57; y: 1.55 } - ] - } - ScatterSeries { - name: "Scatter2" - points: [ - XyPoint { x: 2.0; y: 2.0 }, - XyPoint { x: 2.0; y: 2.1 }, - XyPoint { x: 2.07; y: 2.05 } - ] - } - ScatterSeries { - name: "Scatter3" - points: [ - XyPoint { x: 2.6; y: 2.6 }, - XyPoint { x: 2.6; y: 2.7 }, - XyPoint { x: 2.67; y: 2.65 } - ] + MouseArea { + anchors.fill: parent + onClicked: { + timer.restart(); + loader.source = "View" + (__viewNumber % 3 + 1) + ".qml"; + __viewNumber++; } } } diff --git a/test/qmlchart/resources.qrc b/test/qmlchart/resources.qrc index a9c2b4a..ecec535 100644 --- a/test/qmlchart/resources.qrc +++ b/test/qmlchart/resources.qrc @@ -2,5 +2,8 @@ qml/qmlchart/loader.qml qml/qmlchart/main.qml + qml/qmlchart/View1.qml + qml/qmlchart/View2.qml + qml/qmlchart/View3.qml