diff --git a/qmlplugin/declarativebarseries.cpp b/qmlplugin/declarativebarseries.cpp index e924aad..e76e49e 100644 --- a/qmlplugin/declarativebarseries.cpp +++ b/qmlplugin/declarativebarseries.cpp @@ -53,7 +53,7 @@ void DeclarativeBarSeries::componentComplete() QBarSet *set2 = new QBarSet("Guybrush"); *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; + *set1 << 5 << 1 << 2 << 4 << 1 << 7; *set2 << 3 << 5 << 8 << 13 << 8 << 5; m_series->appendBarSet(set0); diff --git a/qmlplugin/declarativechart.h b/qmlplugin/declarativechart.h index 3e54d74..125271d 100644 --- a/qmlplugin/declarativechart.h +++ b/qmlplugin/declarativechart.h @@ -34,6 +34,7 @@ class DeclarativeChart : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(QChart::ChartTheme theme READ theme WRITE setTheme) + Q_PROPERTY(QString title READ title WRITE setTitle) public: DeclarativeChart(QDeclarativeItem *parent = 0); @@ -46,6 +47,8 @@ public: // From QDeclarativeItem/QGraphicsItem public: void setTheme(QChart::ChartTheme theme) {m_chart->setTheme(theme);} QChart::ChartTheme theme(); + void setTitle(QString title) {m_chart->setTitle(title);} + QString title() { return m_chart->title();} public: // Extending QChart with DeclarativeChart is not possible because QObject does not support diff --git a/test/qmlchart/qml/qmlchart/View1.qml b/test/qmlchart/qml/qmlchart/View1.qml index 0e66371..2f179a8 100644 --- a/test/qmlchart/qml/qmlchart/View1.qml +++ b/test/qmlchart/qml/qmlchart/View1.qml @@ -22,53 +22,30 @@ 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; - } + anchors.fill: parent Chart { - id: chart1 + title: "Car brand shares in Finland" anchors.fill: parent - theme: Chart.ChartThemeDark - - BarSeries { - barCategories: [ "2008", "2009", "2010", "2011", "2012" ] - // TBD: data - } + theme: Chart.ChartThemeLight 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 } + PieSlice { label: "Volvo"; value: 6.8 }, + PieSlice { label: "Others"; value: 52.0 } ] } + + BarSeries { + barCategories: [ "2008", "2009", "2010", "2011", "2012" ] + // data implementation missing + } } } diff --git a/test/qmlchart/qml/qmlchart/View2.qml b/test/qmlchart/qml/qmlchart/View2.qml index b380d34..71f7731 100644 --- a/test/qmlchart/qml/qmlchart/View2.qml +++ b/test/qmlchart/qml/qmlchart/View2.qml @@ -25,6 +25,7 @@ Rectangle { anchors.fill: parent Chart { + title: "Line&Spline" anchors.fill: parent theme: Chart.ChartThemeBrownSand @@ -33,8 +34,10 @@ Rectangle { points: [ XyPoint { x: 0.0; y: 0.0 }, XyPoint { x: 1.1; y: 2.1 }, + XyPoint { x: 1.9; y: 3.3 }, XyPoint { x: 2.9; y: 4.9 }, - XyPoint { x: 3.2; y: 3.0 } + XyPoint { x: 3.2; y: 3.0 }, + XyPoint { x: 4.0; y: 3.3 } ] } @@ -43,8 +46,11 @@ Rectangle { 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 } + XyPoint { x: 1.7; 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 } ] } } diff --git a/test/qmlchart/qml/qmlchart/View3.qml b/test/qmlchart/qml/qmlchart/View3.qml index 0a2c884..32092cb 100644 --- a/test/qmlchart/qml/qmlchart/View3.qml +++ b/test/qmlchart/qml/qmlchart/View3.qml @@ -25,45 +25,103 @@ Rectangle { anchors.fill: parent Chart { + title: "NHL All-Star Team Players" anchors.fill: parent theme: Chart.ChartThemeHighContrast AreaSeries { - name: "Area" + name: "Finnish" points: [ - XyPoint { x: 0.0; y: 1.1 }, - XyPoint { x: 2.5; y: 3.6 }, - XyPoint { x: 3.57; y: 2.55 } + XyPoint { x: 0; y: 0 }, + XyPoint { x: 1; y: 0 }, + XyPoint { x: 2; y: 0 }, + XyPoint { x: 3; y: 0 }, + XyPoint { x: 4; y: 0 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 1 }, + XyPoint { x: 7; y: 0 }, + XyPoint { x: 8; y: 0 }, + XyPoint { x: 9; y: 0 }, + XyPoint { x: 10; y: 0 }, + XyPoint { x: 11; y: 1 } ] lowerPoints: [ - XyPoint { x: 0.0; y: 0.0 }, - XyPoint { x: 2.5; y: 0.0 }, - XyPoint { x: 3.57; y: 0.0 } + XyPoint { x: 0; y: 0 }, + XyPoint { x: 1; y: 0 }, + XyPoint { x: 2; y: 0 }, + XyPoint { x: 3; y: 0 }, + XyPoint { x: 4; y: 0 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 0 }, + XyPoint { x: 7; y: 0 }, + XyPoint { x: 8; y: 0 }, + XyPoint { x: 9; y: 0 }, + XyPoint { x: 10; y: 0 }, + XyPoint { x: 11; y: 0 } ] } - ScatterSeries { - name: "Scatter1" + AreaSeries { + name: "Russian" points: [ - XyPoint { x: 1.5; y: 1.5 }, - XyPoint { x: 1.5; y: 1.6 }, - XyPoint { x: 1.57; y: 1.55 } + XyPoint { x: 0; y: 1 }, + XyPoint { x: 1; y: 1 }, + XyPoint { x: 2; y: 1 }, + XyPoint { x: 3; y: 1 }, + XyPoint { x: 4; y: 1 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 1 }, + XyPoint { x: 7; y: 1 }, + XyPoint { x: 8; y: 4 }, + XyPoint { x: 9; y: 3 }, + XyPoint { x: 10; y: 2 }, + XyPoint { x: 11; y: 1 } ] - } - 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 } + lowerPoints: [ + XyPoint { x: 0; y: 0 }, + XyPoint { x: 1; y: 0 }, + XyPoint { x: 2; y: 0 }, + XyPoint { x: 3; y: 0 }, + XyPoint { x: 4; y: 0 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 0 }, + XyPoint { x: 7; y: 0 }, + XyPoint { x: 8; y: 0 }, + XyPoint { x: 9; y: 0 }, + XyPoint { x: 10; y: 0 }, + XyPoint { x: 11; y: 0 } ] } - ScatterSeries { - name: "Scatter3" + + AreaSeries { + name: "Swedish" points: [ - XyPoint { x: 2.6; y: 2.6 }, - XyPoint { x: 2.6; y: 2.7 }, - XyPoint { x: 2.67; y: 2.65 } + XyPoint { x: 0; y: 1 }, + XyPoint { x: 1; y: 1 }, + XyPoint { x: 2; y: 3 }, + XyPoint { x: 3; y: 3 }, + XyPoint { x: 4; y: 2 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 2 }, + XyPoint { x: 7; y: 1 }, + XyPoint { x: 8; y: 2 }, + XyPoint { x: 9; y: 1 }, + XyPoint { x: 10; y: 3 }, + XyPoint { x: 11; y: 3 } + ] + lowerPoints: [ + XyPoint { x: 0; y: 0 }, + XyPoint { x: 1; y: 0 }, + XyPoint { x: 2; y: 0 }, + XyPoint { x: 3; y: 0 }, + XyPoint { x: 4; y: 0 }, + XyPoint { x: 5; y: 0 }, + XyPoint { x: 6; y: 0 }, + XyPoint { x: 7; y: 0 }, + XyPoint { x: 8; y: 0 }, + XyPoint { x: 9; y: 0 }, + XyPoint { x: 10; y: 0 }, + XyPoint { x: 11; y: 0 } ] } } diff --git a/test/qmlchart/qml/qmlchart/View4.qml b/test/qmlchart/qml/qmlchart/View4.qml new file mode 100644 index 0000000..f1d297a --- /dev/null +++ b/test/qmlchart/qml/qmlchart/View4.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 { + title: "Scatters" + anchors.fill: parent + theme: Chart.ChartThemeBlueCerulean + + ScatterSeries { + id: scatter1 + name: "Scatter1" + points: [ + 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" + points: [ + 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/test/qmlchart/qml/qmlchart/main.qml b/test/qmlchart/qml/qmlchart/main.qml index 38c2f97..0db7f73 100644 --- a/test/qmlchart/qml/qmlchart/main.qml +++ b/test/qmlchart/qml/qmlchart/main.qml @@ -31,9 +31,8 @@ Rectangle { running: true repeat: true interval: 5000 - triggeredOnStart: true + triggeredOnStart: false onTriggered: { - loader.source = "View" + (__viewNumber % 3 + 1) + ".qml"; __viewNumber++; } } @@ -41,13 +40,13 @@ Rectangle { Loader { id: loader anchors.fill: parent + source: "View" + (__viewNumber % 4 + 1) + ".qml"; } 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 ecec535..82eb434 100644 --- a/test/qmlchart/resources.qrc +++ b/test/qmlchart/resources.qrc @@ -5,5 +5,6 @@ qml/qmlchart/View1.qml qml/qmlchart/View2.qml qml/qmlchart/View3.qml + qml/qmlchart/View4.qml