@@ -0,0 +1,35 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include <QtGui/QApplication> | |||
|
22 | #include <QDeclarativeEngine> | |||
|
23 | #include "qmlapplicationviewer.h" | |||
|
24 | ||||
|
25 | Q_DECL_EXPORT int main(int argc, char *argv[]) | |||
|
26 | { | |||
|
27 | QScopedPointer<QApplication> app(createApplication(argc, argv)); | |||
|
28 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |||
|
29 | ||||
|
30 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |||
|
31 | viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml")); | |||
|
32 | viewer->showExpanded(); | |||
|
33 | ||||
|
34 | return app->exec(); | |||
|
35 | } |
@@ -0,0 +1,70 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | ||||
|
23 | Rectangle { | |||
|
24 | id: button | |||
|
25 | height: 25 | |||
|
26 | width: 140 | |||
|
27 | color: unpressedColor | |||
|
28 | radius: 5 | |||
|
29 | property color unpressedColor: "#afafaf" | |||
|
30 | ||||
|
31 | property string text: "button" | |||
|
32 | signal clicked | |||
|
33 | ||||
|
34 | Text { | |||
|
35 | id: buttonText | |||
|
36 | anchors.centerIn: parent | |||
|
37 | text: button.text | |||
|
38 | } | |||
|
39 | ||||
|
40 | MouseArea { | |||
|
41 | anchors.fill: parent | |||
|
42 | onClicked: { | |||
|
43 | button.clicked(); | |||
|
44 | } | |||
|
45 | onPressedChanged: { | |||
|
46 | if (pressed) { | |||
|
47 | button.color = "#efefef"; | |||
|
48 | } else { | |||
|
49 | button.color = unpressedColor; | |||
|
50 | } | |||
|
51 | } | |||
|
52 | onPressAndHold: { | |||
|
53 | repeatTimer.start(); | |||
|
54 | } | |||
|
55 | onReleased: { | |||
|
56 | repeatTimer.stop(); | |||
|
57 | } | |||
|
58 | } | |||
|
59 | ||||
|
60 | Timer { | |||
|
61 | id: repeatTimer | |||
|
62 | interval: 140 | |||
|
63 | repeat: true | |||
|
64 | triggeredOnStart: false | |||
|
65 | running: false | |||
|
66 | onTriggered: { | |||
|
67 | button.clicked(); | |||
|
68 | } | |||
|
69 | } | |||
|
70 | } |
@@ -0,0 +1,110 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "Chart Title" | |||
|
27 | anchors.fill: parent | |||
|
28 | property variant series: chartView | |||
|
29 | ||||
|
30 | LineSeries { | |||
|
31 | name: "line" | |||
|
32 | XYPoint { x: 0; y: 0 } | |||
|
33 | XYPoint { x: 1.1; y: 2.1 } | |||
|
34 | XYPoint { x: 1.9; y: 3.3 } | |||
|
35 | XYPoint { x: 2.1; y: 2.1 } | |||
|
36 | XYPoint { x: 2.9; y: 4.9 } | |||
|
37 | XYPoint { x: 3.4; y: 3.0 } | |||
|
38 | XYPoint { x: 4.1; y: 3.3 } | |||
|
39 | } | |||
|
40 | ||||
|
41 | onVisibleChanged: console.log("chart.onVisibleChanged: " + visible); | |||
|
42 | onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); | |||
|
43 | onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); | |||
|
44 | onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); | |||
|
45 | onTopMarginChanged: { | |||
|
46 | console.log("chart.onTopMarginChanged: " + margin); | |||
|
47 | marginVisualizer.opacity = 1.0; | |||
|
48 | } | |||
|
49 | onBottomMarginChanged: { | |||
|
50 | console.log("chart.onBottomMarginChanged: " + margin); | |||
|
51 | marginVisualizer.opacity = 1.0; | |||
|
52 | } | |||
|
53 | onLeftMarginChanged: { | |||
|
54 | console.log("chart.onLeftMarginChanged: " + margin); | |||
|
55 | marginVisualizer.opacity = 1.0; | |||
|
56 | } | |||
|
57 | onRightMarginChanged: { | |||
|
58 | console.log("chart.onRightMarginChanged: " + margin); | |||
|
59 | marginVisualizer.opacity = 1.0; | |||
|
60 | } | |||
|
61 | ||||
|
62 | legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); | |||
|
63 | legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); | |||
|
64 | legend.onColorChanged: console.log("legend.onColorChanged: " + color); | |||
|
65 | legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); | |||
|
66 | legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); | |||
|
67 | ||||
|
68 | ||||
|
69 | ValuesAxis{ | |||
|
70 | onColorChanged: console.log("axisX.onColorChanged: " + color); | |||
|
71 | onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); | |||
|
72 | onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); | |||
|
73 | onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); | |||
|
74 | onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); | |||
|
75 | onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); | |||
|
76 | onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); | |||
|
77 | onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); | |||
|
78 | onMinChanged: console.log("axisX.onMinChanged: " + min); | |||
|
79 | onMaxChanged: console.log("axisX.onMaxChanged: " + max); | |||
|
80 | } | |||
|
81 | ||||
|
82 | ValuesAxis{ | |||
|
83 | onColorChanged: console.log("axisY.onColorChanged: " + color); | |||
|
84 | onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); | |||
|
85 | onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); | |||
|
86 | onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); | |||
|
87 | onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); | |||
|
88 | onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); | |||
|
89 | onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); | |||
|
90 | onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); | |||
|
91 | onMinChanged: console.log("axisY.onMinChanged: " + min); | |||
|
92 | onMaxChanged: console.log("axisY.onMaxChanged: " + max); | |||
|
93 | } | |||
|
94 | ||||
|
95 | Rectangle { | |||
|
96 | id: marginVisualizer | |||
|
97 | color: "transparent" | |||
|
98 | border.color: "red" | |||
|
99 | anchors.fill: parent | |||
|
100 | anchors.topMargin: parent.topMargin | |||
|
101 | anchors.bottomMargin: parent.bottomMargin | |||
|
102 | anchors.leftMargin: parent.leftMargin | |||
|
103 | anchors.rightMargin: parent.rightMargin | |||
|
104 | opacity: 0.0 | |||
|
105 | onOpacityChanged: if (opacity > 0.9) opacity = 0.0; | |||
|
106 | Behavior on opacity { | |||
|
107 | NumberAnimation { duration: 800 } | |||
|
108 | } | |||
|
109 | } | |||
|
110 | } |
@@ -0,0 +1,49 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "default axes" | |||
|
27 | ||||
|
28 | LineSeries { | |||
|
29 | name: "line series" | |||
|
30 | XYPoint { x: 0; y: 0 } | |||
|
31 | XYPoint { x: 1.1; y: 2.1 } | |||
|
32 | XYPoint { x: 1.9; y: 3.3 } | |||
|
33 | XYPoint { x: 2.1; y: 2.1 } | |||
|
34 | XYPoint { x: 2.9; y: 4.9 } | |||
|
35 | XYPoint { x: 3.4; y: 3.0 } | |||
|
36 | XYPoint { x: 4.1; y: 3.3 } | |||
|
37 | } | |||
|
38 | ||||
|
39 | ScatterSeries { | |||
|
40 | name: "scatter series" | |||
|
41 | XYPoint { x: 0; y: 0 } | |||
|
42 | XYPoint { x: 1.1; y: 2.1 } | |||
|
43 | XYPoint { x: 1.9; y: 3.3 } | |||
|
44 | XYPoint { x: 2.1; y: 2.1 } | |||
|
45 | XYPoint { x: 2.9; y: 4.9 } | |||
|
46 | XYPoint { x: 3.4; y: 3.0 } | |||
|
47 | XYPoint { x: 4.1; y: 3.3 } | |||
|
48 | } | |||
|
49 | } |
@@ -0,0 +1,64 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | title: "user defined axes" | |||
|
26 | ||||
|
27 | ValuesAxis { | |||
|
28 | id: axisX | |||
|
29 | min: 0 | |||
|
30 | max: 10 | |||
|
31 | } | |||
|
32 | ||||
|
33 | ValuesAxis { | |||
|
34 | id: axisY | |||
|
35 | min: 0 | |||
|
36 | max: 6 | |||
|
37 | } | |||
|
38 | ||||
|
39 | LineSeries { | |||
|
40 | name: "line series" | |||
|
41 | axisX: axisX | |||
|
42 | axisY: axisY | |||
|
43 | XYPoint { x: 0; y: 0 } | |||
|
44 | XYPoint { x: 1.1; y: 2.1 } | |||
|
45 | XYPoint { x: 1.9; y: 3.3 } | |||
|
46 | XYPoint { x: 2.1; y: 2.1 } | |||
|
47 | XYPoint { x: 2.9; y: 4.9 } | |||
|
48 | XYPoint { x: 3.4; y: 3.0 } | |||
|
49 | XYPoint { x: 4.1; y: 3.3 } | |||
|
50 | } | |||
|
51 | ||||
|
52 | ScatterSeries { | |||
|
53 | name: "scatter series" | |||
|
54 | axisX: axisX | |||
|
55 | axisY: axisY | |||
|
56 | XYPoint { x: 0; y: 0 } | |||
|
57 | XYPoint { x: 1.1; y: 2.1 } | |||
|
58 | XYPoint { x: 1.9; y: 3.3 } | |||
|
59 | XYPoint { x: 2.1; y: 2.1 } | |||
|
60 | XYPoint { x: 2.9; y: 4.9 } | |||
|
61 | XYPoint { x: 3.4; y: 3.0 } | |||
|
62 | XYPoint { x: 4.1; y: 3.3 } | |||
|
63 | } | |||
|
64 | } |
@@ -0,0 +1,71 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "user defined axes" | |||
|
27 | ||||
|
28 | ValuesAxis { | |||
|
29 | id: axisX | |||
|
30 | min: 0 | |||
|
31 | max: 10 | |||
|
32 | // TODO: property to fix orientation to "X" to make this the X default axis for all series | |||
|
33 | // that don't have user defined X axis | |||
|
34 | } | |||
|
35 | ||||
|
36 | ValuesAxis { | |||
|
37 | id: axisY | |||
|
38 | min: 0 | |||
|
39 | max: 5 | |||
|
40 | // TODO: property to fix orientation to "Y" to make this the Y default axis for all series | |||
|
41 | // that don't have user defined Y axis | |||
|
42 | } | |||
|
43 | ||||
|
44 | LineSeries { | |||
|
45 | name: "line series" | |||
|
46 | XYPoint { x: 0; y: 0 } | |||
|
47 | XYPoint { x: 1.1; y: 2.1 } | |||
|
48 | XYPoint { x: 1.9; y: 3.3 } | |||
|
49 | XYPoint { x: 2.1; y: 2.1 } | |||
|
50 | XYPoint { x: 2.9; y: 4.9 } | |||
|
51 | XYPoint { x: 3.4; y: 3.0 } | |||
|
52 | XYPoint { x: 4.1; y: 3.3 } | |||
|
53 | } | |||
|
54 | ||||
|
55 | ScatterSeries { | |||
|
56 | name: "scatter series" | |||
|
57 | id: scatter | |||
|
58 | XYPoint { x: 0; y: 0 } | |||
|
59 | XYPoint { x: 1.1; y: 2.1 } | |||
|
60 | XYPoint { x: 1.9; y: 3.3 } | |||
|
61 | XYPoint { x: 2.1; y: 2.1 } | |||
|
62 | XYPoint { x: 2.9; y: 4.9 } | |||
|
63 | XYPoint { x: 3.4; y: 3.0 } | |||
|
64 | XYPoint { x: 4.1; y: 3.3 } | |||
|
65 | } | |||
|
66 | ||||
|
67 | Component.onCompleted: { | |||
|
68 | // You can also set the axes dynamically | |||
|
69 | chartView.setAxisX(axisX, scatter); | |||
|
70 | } | |||
|
71 | } |
@@ -0,0 +1,74 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | title: "configuring dynamically" | |||
|
26 | id: chartView | |||
|
27 | property int index: 0 | |||
|
28 | ||||
|
29 | Timer { | |||
|
30 | interval: 1000 | |||
|
31 | repeat: true | |||
|
32 | running: true | |||
|
33 | onTriggered: { | |||
|
34 | switch (index) { | |||
|
35 | case 0: | |||
|
36 | chartView.axisX(lineSeries).max = 5; | |||
|
37 | chartView.axisY(lineSeries).max = 5; | |||
|
38 | break; | |||
|
39 | case 1: | |||
|
40 | chartView.axisX(scatterSeries).max = 10; | |||
|
41 | chartView.axisY(scatterSeries).max = 10; | |||
|
42 | break; | |||
|
43 | default: | |||
|
44 | chartView.axisX().max = 15; | |||
|
45 | chartView.axisY().max = 15; | |||
|
46 | } | |||
|
47 | index = (index + 1) % 3; | |||
|
48 | } | |||
|
49 | } | |||
|
50 | ||||
|
51 | LineSeries { | |||
|
52 | id: lineSeries | |||
|
53 | name: "line series" | |||
|
54 | XYPoint { x: 0; y: 0 } | |||
|
55 | XYPoint { x: 1.1; y: 2.1 } | |||
|
56 | XYPoint { x: 1.9; y: 3.3 } | |||
|
57 | XYPoint { x: 2.1; y: 2.1 } | |||
|
58 | XYPoint { x: 2.9; y: 4.9 } | |||
|
59 | XYPoint { x: 3.4; y: 3.0 } | |||
|
60 | XYPoint { x: 4.1; y: 3.3 } | |||
|
61 | } | |||
|
62 | ||||
|
63 | ScatterSeries { | |||
|
64 | id: scatterSeries | |||
|
65 | name: "scatter series" | |||
|
66 | XYPoint { x: 0; y: 0 } | |||
|
67 | XYPoint { x: 1.1; y: 2.1 } | |||
|
68 | XYPoint { x: 1.9; y: 3.3 } | |||
|
69 | XYPoint { x: 2.1; y: 2.1 } | |||
|
70 | XYPoint { x: 2.9; y: 4.9 } | |||
|
71 | XYPoint { x: 3.4; y: 3.0 } | |||
|
72 | XYPoint { x: 4.1; y: 3.3 } | |||
|
73 | } | |||
|
74 | } |
@@ -0,0 +1,84 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | title: "series specific dynamic axes" | |||
|
26 | id: chartView | |||
|
27 | property int index: 0 | |||
|
28 | ||||
|
29 | Timer { | |||
|
30 | interval: 1000 | |||
|
31 | repeat: true | |||
|
32 | running: true | |||
|
33 | onTriggered: { | |||
|
34 | switch (index) { | |||
|
35 | case 0: | |||
|
36 | lineAxisX.max = 5; | |||
|
37 | lineAxisY.max = 5; | |||
|
38 | scatterAxisX.max = 10; | |||
|
39 | scatterAxisY.max = 10; | |||
|
40 | break; | |||
|
41 | case 1: | |||
|
42 | lineAxisX.max = 10; | |||
|
43 | lineAxisY.max = 10; | |||
|
44 | scatterAxisX.max = 5; | |||
|
45 | scatterAxisY.max = 5; | |||
|
46 | break; | |||
|
47 | default: | |||
|
48 | chartView.axisX().max = 2; | |||
|
49 | chartView.axisY().max = 2; | |||
|
50 | } | |||
|
51 | index = (index + 1) % 3; | |||
|
52 | } | |||
|
53 | } | |||
|
54 | ||||
|
55 | LineSeries { | |||
|
56 | id: lineSeries | |||
|
57 | name: "line series" | |||
|
58 | axisX: ValuesAxis { id: lineAxisX } | |||
|
59 | axisY: ValuesAxis { id: lineAxisY } | |||
|
60 | ||||
|
61 | XYPoint { x: 0; y: 0 } | |||
|
62 | XYPoint { x: 1.1; y: 2.1 } | |||
|
63 | XYPoint { x: 1.9; y: 3.3 } | |||
|
64 | XYPoint { x: 2.1; y: 2.1 } | |||
|
65 | XYPoint { x: 2.9; y: 4.9 } | |||
|
66 | XYPoint { x: 3.4; y: 3.0 } | |||
|
67 | XYPoint { x: 4.1; y: 3.3 } | |||
|
68 | } | |||
|
69 | ||||
|
70 | ScatterSeries { | |||
|
71 | id: scatterSeries | |||
|
72 | name: "scatter series" | |||
|
73 | axisX: ValuesAxis { id: scatterAxisX } | |||
|
74 | axisY: ValuesAxis { id: scatterAxisY } | |||
|
75 | ||||
|
76 | XYPoint { x: 0; y: 0 } | |||
|
77 | XYPoint { x: 1.1; y: 2.1 } | |||
|
78 | XYPoint { x: 1.9; y: 3.3 } | |||
|
79 | XYPoint { x: 2.1; y: 2.1 } | |||
|
80 | XYPoint { x: 2.9; y: 4.9 } | |||
|
81 | XYPoint { x: 3.4; y: 3.0 } | |||
|
82 | XYPoint { x: 4.1; y: 3.3 } | |||
|
83 | } | |||
|
84 | } |
@@ -0,0 +1,66 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "dynamically created series" | |||
|
27 | property int index: 0 | |||
|
28 | ||||
|
29 | Timer { | |||
|
30 | interval: 1000 | |||
|
31 | repeat: true | |||
|
32 | running: true | |||
|
33 | onTriggered: { | |||
|
34 | switch (index) { | |||
|
35 | case 0: | |||
|
36 | while (chartView.count) | |||
|
37 | chartView.series(0).destroy(); | |||
|
38 | var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); | |||
|
39 | line.append(0, 0); | |||
|
40 | line.append(1.1, 2.1); | |||
|
41 | line.append(1.9, 3.3); | |||
|
42 | line.append(2.1, 2.1); | |||
|
43 | line.append(2.9, 4.9); | |||
|
44 | line.append(3.4, 3.0); | |||
|
45 | line.append(4.1, 3.3); | |||
|
46 | break; | |||
|
47 | case 1: | |||
|
48 | chartView.axisX().min = 0; | |||
|
49 | chartView.axisX().max = 4.5; | |||
|
50 | chartView.axisY().min = 0; | |||
|
51 | chartView.axisY().max = 4.5; | |||
|
52 | break; | |||
|
53 | default: | |||
|
54 | var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); | |||
|
55 | scatter.append(0, 0); | |||
|
56 | scatter.append(1.1, 2.1); | |||
|
57 | scatter.append(1.9, 3.3); | |||
|
58 | scatter.append(2.1, 2.1); | |||
|
59 | scatter.append(2.9, 4.9); | |||
|
60 | scatter.append(3.4, 3.0); | |||
|
61 | scatter.append(4.1, 3.3); | |||
|
62 | } | |||
|
63 | index = (index + 1) % 3; | |||
|
64 | } | |||
|
65 | } | |||
|
66 | } |
@@ -0,0 +1,64 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "switching axes dynamically" | |||
|
27 | ||||
|
28 | Timer { | |||
|
29 | interval: 1000 | |||
|
30 | repeat: true | |||
|
31 | running: true | |||
|
32 | onTriggered: { | |||
|
33 | if (lineSeries.axisX == valuesAxis1) | |||
|
34 | lineSeries.axisX = valuesAxis2; | |||
|
35 | else | |||
|
36 | lineSeries.axisX = valuesAxis1; | |||
|
37 | } | |||
|
38 | } | |||
|
39 | ||||
|
40 | ValuesAxis { | |||
|
41 | id: valuesAxis1 | |||
|
42 | min: 0 | |||
|
43 | max: 5 | |||
|
44 | } | |||
|
45 | ||||
|
46 | ValuesAxis { | |||
|
47 | id: valuesAxis2 | |||
|
48 | min: 1 | |||
|
49 | max: 6 | |||
|
50 | } | |||
|
51 | ||||
|
52 | LineSeries { | |||
|
53 | id: lineSeries | |||
|
54 | name: "line series" | |||
|
55 | axisX: valuesAxis1 | |||
|
56 | XYPoint { x: 0; y: 0 } | |||
|
57 | XYPoint { x: 1.1; y: 2.1 } | |||
|
58 | XYPoint { x: 1.9; y: 3.3 } | |||
|
59 | XYPoint { x: 2.1; y: 2.1 } | |||
|
60 | XYPoint { x: 2.9; y: 4.9 } | |||
|
61 | XYPoint { x: 3.4; y: 3.0 } | |||
|
62 | XYPoint { x: 4.1; y: 3.3 } | |||
|
63 | } | |||
|
64 | } |
@@ -0,0 +1,43 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "axis scale; different series" | |||
|
27 | ||||
|
28 | LineSeries { | |||
|
29 | name: "line series" | |||
|
30 | XYPoint { x: 0; y: 0 } | |||
|
31 | XYPoint { x: 1.1; y: 2.1 } | |||
|
32 | XYPoint { x: 1.9; y: 3.3 } | |||
|
33 | XYPoint { x: 2.1; y: 2.1 } | |||
|
34 | } | |||
|
35 | ||||
|
36 | ScatterSeries { | |||
|
37 | name: "scatter series" | |||
|
38 | XYPoint { x: 2.1; y: 2.1 } | |||
|
39 | XYPoint { x: 2.9; y: 4.9 } | |||
|
40 | XYPoint { x: 3.4; y: 3.0 } | |||
|
41 | XYPoint { x: 4.1; y: 3.3 } | |||
|
42 | } | |||
|
43 | } |
@@ -0,0 +1,56 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "Deprecated code" | |||
|
27 | property int index: 0 | |||
|
28 | ||||
|
29 | Component.onCompleted: { | |||
|
30 | // Calling createDefaultAxes in onCompleted is now deprecated. It needs to be tested, | |||
|
31 | // though, because some application may still use it | |||
|
32 | chartView.createDefaultAxes(); | |||
|
33 | } | |||
|
34 | ||||
|
35 | LineSeries { | |||
|
36 | name: "line series" | |||
|
37 | XYPoint { x: 0; y: 0 } | |||
|
38 | XYPoint { x: 1.1; y: 2.1 } | |||
|
39 | XYPoint { x: 1.9; y: 3.3 } | |||
|
40 | XYPoint { x: 2.1; y: 2.1 } | |||
|
41 | XYPoint { x: 2.9; y: 4.9 } | |||
|
42 | XYPoint { x: 3.4; y: 3.0 } | |||
|
43 | XYPoint { x: 4.1; y: 3.3 } | |||
|
44 | } | |||
|
45 | ||||
|
46 | ScatterSeries { | |||
|
47 | name: "scatter series" | |||
|
48 | XYPoint { x: 0; y: 0 } | |||
|
49 | XYPoint { x: 1.1; y: 2.1 } | |||
|
50 | XYPoint { x: 1.9; y: 3.3 } | |||
|
51 | XYPoint { x: 2.1; y: 2.1 } | |||
|
52 | XYPoint { x: 2.9; y: 4.9 } | |||
|
53 | XYPoint { x: 3.4; y: 3.0 } | |||
|
54 | XYPoint { x: 4.1; y: 3.3 } | |||
|
55 | } | |||
|
56 | } |
@@ -0,0 +1,56 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | import QtCommercial.Chart 1.0 | |||
|
23 | ||||
|
24 | ChartView { | |||
|
25 | id: chartView | |||
|
26 | title: "Deprecated code" | |||
|
27 | property int index: 0 | |||
|
28 | ||||
|
29 | Component.onCompleted: { | |||
|
30 | // Calling createDefaultAxes in onCompleted is now deprecated. It needs to be tested, | |||
|
31 | // though, because some application may still use it | |||
|
32 | chartView.createDefaultAxes(); | |||
|
33 | } | |||
|
34 | ||||
|
35 | LineSeries { | |||
|
36 | name: "line series" | |||
|
37 | XYPoint { x: 0; y: 0 } | |||
|
38 | XYPoint { x: 1.1; y: 2.1 } | |||
|
39 | XYPoint { x: 1.9; y: 3.3 } | |||
|
40 | XYPoint { x: 2.1; y: 2.1 } | |||
|
41 | XYPoint { x: 2.9; y: 4.9 } | |||
|
42 | XYPoint { x: 3.4; y: 3.0 } | |||
|
43 | XYPoint { x: 4.1; y: 3.3 } | |||
|
44 | } | |||
|
45 | ||||
|
46 | ScatterSeries { | |||
|
47 | name: "scatter series" | |||
|
48 | XYPoint { x: 0; y: 0 } | |||
|
49 | XYPoint { x: 1.1; y: 2.1 } | |||
|
50 | XYPoint { x: 1.9; y: 3.3 } | |||
|
51 | XYPoint { x: 2.1; y: 2.1 } | |||
|
52 | XYPoint { x: 2.9; y: 4.9 } | |||
|
53 | XYPoint { x: 3.4; y: 3.0 } | |||
|
54 | XYPoint { x: 4.1; y: 3.3 } | |||
|
55 | } | |||
|
56 | } |
@@ -0,0 +1,84 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | import QtQuick 1.0 | |||
|
22 | ||||
|
23 | Rectangle { | |||
|
24 | id: main | |||
|
25 | width: 400 | |||
|
26 | height: 300 | |||
|
27 | property int viewNumber: 0 | |||
|
28 | ||||
|
29 | Row { | |||
|
30 | anchors.fill: parent | |||
|
31 | anchors.topMargin: 10 | |||
|
32 | ||||
|
33 | Loader { | |||
|
34 | id: chartLoader | |||
|
35 | width: parent.width - buttonColumn.width | |||
|
36 | height: parent.height | |||
|
37 | source: "Chart" + viewNumber + ".qml" | |||
|
38 | } | |||
|
39 | ||||
|
40 | Column { | |||
|
41 | id: buttonColumn | |||
|
42 | width: 150 | |||
|
43 | height: parent.height | |||
|
44 | spacing: 5 | |||
|
45 | ||||
|
46 | Button { | |||
|
47 | text: "Default" | |||
|
48 | onClicked: viewNumber = 0; | |||
|
49 | } | |||
|
50 | Button { | |||
|
51 | text: "User defined" | |||
|
52 | onClicked: viewNumber = 1; | |||
|
53 | } | |||
|
54 | Button { | |||
|
55 | text: "Chart axes" | |||
|
56 | onClicked: viewNumber = 2; | |||
|
57 | } | |||
|
58 | Button { | |||
|
59 | text: "Configuring dynamically" | |||
|
60 | onClicked: viewNumber = 3; | |||
|
61 | } | |||
|
62 | Button { | |||
|
63 | text: "Series specific dynamic" | |||
|
64 | onClicked: viewNumber = 4; | |||
|
65 | } | |||
|
66 | Button { | |||
|
67 | text: "Creating dynamically" | |||
|
68 | onClicked: viewNumber = 5; | |||
|
69 | } | |||
|
70 | Button { | |||
|
71 | text: "Switching dynamically" | |||
|
72 | onClicked: viewNumber = 6; | |||
|
73 | } | |||
|
74 | Button { | |||
|
75 | text: "Axis scale" | |||
|
76 | onClicked: viewNumber = 7; | |||
|
77 | } | |||
|
78 | Button { | |||
|
79 | text: "Legacy" | |||
|
80 | onClicked: viewNumber = 8; | |||
|
81 | } | |||
|
82 | } | |||
|
83 | } | |||
|
84 | } |
@@ -0,0 +1,200 | |||||
|
1 | // checksum 0x78c version 0x60010 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #include "qmlapplicationviewer.h" | |||
|
12 | ||||
|
13 | #include <QtCore/QDir> | |||
|
14 | #include <QtCore/QFileInfo> | |||
|
15 | #include <QtDeclarative/QDeclarativeComponent> | |||
|
16 | #include <QtDeclarative/QDeclarativeEngine> | |||
|
17 | #include <QtDeclarative/QDeclarativeContext> | |||
|
18 | #include <QtGui/QApplication> | |||
|
19 | ||||
|
20 | #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN | |||
|
21 | ||||
|
22 | #ifdef HARMATTAN_BOOSTER | |||
|
23 | #include <MDeclarativeCache> | |||
|
24 | #endif | |||
|
25 | ||||
|
26 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
27 | ||||
|
28 | #include <qt_private/qdeclarativedebughelper_p.h> | |||
|
29 | ||||
|
30 | #if !defined(NO_JSDEBUGGER) | |||
|
31 | #include <jsdebuggeragent.h> | |||
|
32 | #endif | |||
|
33 | #if !defined(NO_QMLOBSERVER) | |||
|
34 | #include <qdeclarativeviewobserver.h> | |||
|
35 | #endif | |||
|
36 | ||||
|
37 | // Enable debugging before any QDeclarativeEngine is created | |||
|
38 | struct QmlJsDebuggingEnabler | |||
|
39 | { | |||
|
40 | QmlJsDebuggingEnabler() | |||
|
41 | { | |||
|
42 | QDeclarativeDebugHelper::enableDebugging(); | |||
|
43 | } | |||
|
44 | }; | |||
|
45 | ||||
|
46 | // Execute code in constructor before first QDeclarativeEngine is instantiated | |||
|
47 | static QmlJsDebuggingEnabler enableDebuggingHelper; | |||
|
48 | ||||
|
49 | #endif // QMLJSDEBUGGER | |||
|
50 | ||||
|
51 | class QmlApplicationViewerPrivate | |||
|
52 | { | |||
|
53 | QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} | |||
|
54 | ||||
|
55 | QString mainQmlFile; | |||
|
56 | QDeclarativeView *view; | |||
|
57 | friend class QmlApplicationViewer; | |||
|
58 | QString adjustPath(const QString &path); | |||
|
59 | }; | |||
|
60 | ||||
|
61 | QString QmlApplicationViewerPrivate::adjustPath(const QString &path) | |||
|
62 | { | |||
|
63 | #ifdef Q_OS_UNIX | |||
|
64 | #ifdef Q_OS_MAC | |||
|
65 | if (!QDir::isAbsolutePath(path)) | |||
|
66 | return QCoreApplication::applicationDirPath() | |||
|
67 | + QLatin1String("/../Resources/") + path; | |||
|
68 | #else | |||
|
69 | QString pathInInstallDir; | |||
|
70 | const QString applicationDirPath = QCoreApplication::applicationDirPath(); | |||
|
71 | pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); | |||
|
72 | ||||
|
73 | if (QFileInfo(pathInInstallDir).exists()) | |||
|
74 | return pathInInstallDir; | |||
|
75 | #endif | |||
|
76 | #endif | |||
|
77 | return path; | |||
|
78 | } | |||
|
79 | ||||
|
80 | QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) | |||
|
81 | : QDeclarativeView(parent) | |||
|
82 | , d(new QmlApplicationViewerPrivate(this)) | |||
|
83 | { | |||
|
84 | connect(engine(), SIGNAL(quit()), SLOT(close())); | |||
|
85 | setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
86 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
87 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
88 | #if !defined(NO_JSDEBUGGER) | |||
|
89 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |||
|
90 | #endif | |||
|
91 | #if !defined(NO_QMLOBSERVER) | |||
|
92 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |||
|
93 | #endif | |||
|
94 | #endif | |||
|
95 | } | |||
|
96 | ||||
|
97 | QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) | |||
|
98 | : QDeclarativeView(parent) | |||
|
99 | , d(new QmlApplicationViewerPrivate(view)) | |||
|
100 | { | |||
|
101 | connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); | |||
|
102 | view->setResizeMode(QDeclarativeView::SizeRootObjectToView); | |||
|
103 | // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in | |||
|
104 | #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 | |||
|
105 | #if !defined(NO_JSDEBUGGER) | |||
|
106 | new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); | |||
|
107 | #endif | |||
|
108 | #if !defined(NO_QMLOBSERVER) | |||
|
109 | new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); | |||
|
110 | #endif | |||
|
111 | #endif | |||
|
112 | } | |||
|
113 | ||||
|
114 | QmlApplicationViewer::~QmlApplicationViewer() | |||
|
115 | { | |||
|
116 | delete d; | |||
|
117 | } | |||
|
118 | ||||
|
119 | QmlApplicationViewer *QmlApplicationViewer::create() | |||
|
120 | { | |||
|
121 | #ifdef HARMATTAN_BOOSTER | |||
|
122 | return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); | |||
|
123 | #else | |||
|
124 | return new QmlApplicationViewer(); | |||
|
125 | #endif | |||
|
126 | } | |||
|
127 | ||||
|
128 | void QmlApplicationViewer::setMainQmlFile(const QString &file) | |||
|
129 | { | |||
|
130 | d->mainQmlFile = d->adjustPath(file); | |||
|
131 | d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); | |||
|
132 | } | |||
|
133 | ||||
|
134 | void QmlApplicationViewer::addImportPath(const QString &path) | |||
|
135 | { | |||
|
136 | d->view->engine()->addImportPath(d->adjustPath(path)); | |||
|
137 | } | |||
|
138 | ||||
|
139 | void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) | |||
|
140 | { | |||
|
141 | #if defined(Q_OS_SYMBIAN) | |||
|
142 | // If the version of Qt on the device is < 4.7.2, that attribute won't work | |||
|
143 | if (orientation != ScreenOrientationAuto) { | |||
|
144 | const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); | |||
|
145 | if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { | |||
|
146 | qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); | |||
|
147 | return; | |||
|
148 | } | |||
|
149 | } | |||
|
150 | #endif // Q_OS_SYMBIAN | |||
|
151 | ||||
|
152 | Qt::WidgetAttribute attribute; | |||
|
153 | switch (orientation) { | |||
|
154 | #if QT_VERSION < 0x040702 | |||
|
155 | // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes | |||
|
156 | case ScreenOrientationLockPortrait: | |||
|
157 | attribute = static_cast<Qt::WidgetAttribute>(128); | |||
|
158 | break; | |||
|
159 | case ScreenOrientationLockLandscape: | |||
|
160 | attribute = static_cast<Qt::WidgetAttribute>(129); | |||
|
161 | break; | |||
|
162 | default: | |||
|
163 | case ScreenOrientationAuto: | |||
|
164 | attribute = static_cast<Qt::WidgetAttribute>(130); | |||
|
165 | break; | |||
|
166 | #else // QT_VERSION < 0x040702 | |||
|
167 | case ScreenOrientationLockPortrait: | |||
|
168 | attribute = Qt::WA_LockPortraitOrientation; | |||
|
169 | break; | |||
|
170 | case ScreenOrientationLockLandscape: | |||
|
171 | attribute = Qt::WA_LockLandscapeOrientation; | |||
|
172 | break; | |||
|
173 | default: | |||
|
174 | case ScreenOrientationAuto: | |||
|
175 | attribute = Qt::WA_AutoOrientation; | |||
|
176 | break; | |||
|
177 | #endif // QT_VERSION < 0x040702 | |||
|
178 | }; | |||
|
179 | setAttribute(attribute, true); | |||
|
180 | } | |||
|
181 | ||||
|
182 | void QmlApplicationViewer::showExpanded() | |||
|
183 | { | |||
|
184 | #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) | |||
|
185 | d->view->showFullScreen(); | |||
|
186 | #elif defined(Q_WS_MAEMO_5) | |||
|
187 | d->view->showMaximized(); | |||
|
188 | #else | |||
|
189 | d->view->show(); | |||
|
190 | #endif | |||
|
191 | } | |||
|
192 | ||||
|
193 | QApplication *createApplication(int &argc, char **argv) | |||
|
194 | { | |||
|
195 | #ifdef HARMATTAN_BOOSTER | |||
|
196 | return MDeclarativeCache::qApplication(argc, argv); | |||
|
197 | #else | |||
|
198 | return new QApplication(argc, argv); | |||
|
199 | #endif | |||
|
200 | } |
@@ -0,0 +1,47 | |||||
|
1 | // checksum 0x82ed version 0x60010 | |||
|
2 | /* | |||
|
3 | This file was generated by the Qt Quick Application wizard of Qt Creator. | |||
|
4 | QmlApplicationViewer is a convenience class containing mobile device specific | |||
|
5 | code such as screen orientation handling. Also QML paths and debugging are | |||
|
6 | handled here. | |||
|
7 | It is recommended not to modify this file, since newer versions of Qt Creator | |||
|
8 | may offer an updated version of it. | |||
|
9 | */ | |||
|
10 | ||||
|
11 | #ifndef QMLAPPLICATIONVIEWER_H | |||
|
12 | #define QMLAPPLICATIONVIEWER_H | |||
|
13 | ||||
|
14 | #include <QtDeclarative/QDeclarativeView> | |||
|
15 | ||||
|
16 | class QmlApplicationViewer : public QDeclarativeView | |||
|
17 | { | |||
|
18 | Q_OBJECT | |||
|
19 | ||||
|
20 | public: | |||
|
21 | enum ScreenOrientation { | |||
|
22 | ScreenOrientationLockPortrait, | |||
|
23 | ScreenOrientationLockLandscape, | |||
|
24 | ScreenOrientationAuto | |||
|
25 | }; | |||
|
26 | ||||
|
27 | explicit QmlApplicationViewer(QWidget *parent = 0); | |||
|
28 | virtual ~QmlApplicationViewer(); | |||
|
29 | ||||
|
30 | static QmlApplicationViewer *create(); | |||
|
31 | ||||
|
32 | void setMainQmlFile(const QString &file); | |||
|
33 | void addImportPath(const QString &path); | |||
|
34 | ||||
|
35 | // Note that this will only have an effect on Symbian and Fremantle. | |||
|
36 | void setOrientation(ScreenOrientation orientation); | |||
|
37 | ||||
|
38 | void showExpanded(); | |||
|
39 | ||||
|
40 | private: | |||
|
41 | explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); | |||
|
42 | class QmlApplicationViewerPrivate *d; | |||
|
43 | }; | |||
|
44 | ||||
|
45 | QApplication *createApplication(int &argc, char **argv); | |||
|
46 | ||||
|
47 | #endif // QMLAPPLICATIONVIEWER_H |
@@ -0,0 +1,13 | |||||
|
1 | QT += declarative | |||
|
2 | ||||
|
3 | SOURCES += $$PWD/qmlapplicationviewer.cpp | |||
|
4 | HEADERS += $$PWD/qmlapplicationviewer.h | |||
|
5 | INCLUDEPATH += $$PWD | |||
|
6 | ||||
|
7 | # Include JS debugger library if QMLJSDEBUGGER_PATH is set | |||
|
8 | !isEmpty(QMLJSDEBUGGER_PATH) { | |||
|
9 | include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) | |||
|
10 | } else { | |||
|
11 | DEFINES -= QMLJSDEBUGGER | |||
|
12 | } | |||
|
13 |
@@ -0,0 +1,8 | |||||
|
1 | !include( ../tests.pri ) { | |||
|
2 | error( "Couldn't find the test.pri file!" ) | |||
|
3 | } | |||
|
4 | ||||
|
5 | RESOURCES += resources.qrc | |||
|
6 | SOURCES += main.cpp | |||
|
7 | ||||
|
8 | include(qmlapplicationviewer/qmlapplicationviewer.pri) |
@@ -0,0 +1,15 | |||||
|
1 | <RCC> | |||
|
2 | <qresource prefix="/"> | |||
|
3 | <file>qml/qmlchartaxis/main.qml</file> | |||
|
4 | <file>qml/qmlchartaxis/Button.qml</file> | |||
|
5 | <file>qml/qmlchartaxis/Chart0.qml</file> | |||
|
6 | <file>qml/qmlchartaxis/Chart1.qml</file> | |||
|
7 | <file>qml/qmlchartaxis/Chart2.qml</file> | |||
|
8 | <file>qml/qmlchartaxis/Chart3.qml</file> | |||
|
9 | <file>qml/qmlchartaxis/Chart4.qml</file> | |||
|
10 | <file>qml/qmlchartaxis/Chart5.qml</file> | |||
|
11 | <file>qml/qmlchartaxis/Chart6.qml</file> | |||
|
12 | <file>qml/qmlchartaxis/Chart7.qml</file> | |||
|
13 | <file>qml/qmlchartaxis/Chart8.qml</file> | |||
|
14 | </qresource> | |||
|
15 | </RCC> |
@@ -35,9 +35,6 Rectangle { | |||||
35 |
|
35 | |||
36 | PieSeries { |
|
36 | PieSeries { | |
37 | id: pieSeries |
|
37 | id: pieSeries | |
38 | onClicked: { |
|
|||
39 | slice.exploded = !slice.exploded; |
|
|||
40 | } |
|
|||
41 | PieSlice { label: "Volkswagen"; value: 13.5 } |
|
38 | PieSlice { label: "Volkswagen"; value: 13.5 } | |
42 | PieSlice { label: "Toyota"; value: 10.9 } |
|
39 | PieSlice { label: "Toyota"; value: 10.9 } | |
43 | PieSlice { label: "Ford"; value: 8.6 } |
|
40 | PieSlice { label: "Ford"; value: 8.6 } | |
@@ -45,11 +42,11 Rectangle { | |||||
45 | PieSlice { label: "Volvo"; value: 6.8 } |
|
42 | PieSlice { label: "Volvo"; value: 6.8 } | |
46 | } |
|
43 | } | |
47 | } |
|
44 | } | |
48 | //![1] |
|
|||
49 |
|
|
45 | ||
50 | Component.onCompleted: { |
|
46 | Component.onCompleted: { | |
51 |
// You can also |
|
47 | // You can also manipulate slices dynamically | |
52 | otherSlice = pieSeries.append("Others", 52.0); |
|
48 | otherSlice = pieSeries.append("Others", 52.0); | |
53 | pieSeries.find("Volkswagen").exploded = true; |
|
49 | pieSeries.find("Volkswagen").exploded = true; | |
54 | } |
|
50 | } | |
|
51 | //![1] | |||
55 | } |
|
52 | } |
@@ -29,20 +29,13 Rectangle { | |||||
29 | title: "Horizontal Stacked Bar series" |
|
29 | title: "Horizontal Stacked Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id: myAxis; |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | HorizontalStackedBarSeries { |
|
33 | HorizontalStackedBarSeries { | |
37 | id: mySeries; |
|
34 | axisY: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
38 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisY(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
39 | } | |
47 | //![1] |
|
40 | //![1] | |
48 | } |
|
41 | } |
@@ -29,20 +29,13 Rectangle { | |||||
29 | title: "Horizontal Percent Bar series" |
|
29 | title: "Horizontal Percent Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id: myAxis |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | HorizontalPercentBarSeries { |
|
33 | HorizontalPercentBarSeries { | |
37 | id: mySeries |
|
34 | axisY: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
38 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisY(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
39 | } | |
47 | //![1] |
|
40 | //![1] | |
48 | } |
|
41 | } |
@@ -39,10 +39,6 Rectangle { | |||||
39 | XYPoint { x: 3.4; y: 3.0 } |
|
39 | XYPoint { x: 3.4; y: 3.0 } | |
40 | XYPoint { x: 4.1; y: 3.3 } |
|
40 | XYPoint { x: 4.1; y: 3.3 } | |
41 | } |
|
41 | } | |
42 |
|
||||
43 | Component.onCompleted: { |
|
|||
44 | createDefaultAxes(); |
|
|||
45 | } |
|
|||
46 | } |
|
42 | } | |
47 | //![1] |
|
43 | //![1] | |
48 | } |
|
44 | } |
@@ -31,7 +31,7 Rectangle { | |||||
31 |
|
31 | |||
32 | SplineSeries { |
|
32 | SplineSeries { | |
33 | name: "SplineSeries" |
|
33 | name: "SplineSeries" | |
34 |
XYPoint { x: 0; y: 0. |
|
34 | XYPoint { x: 0; y: 0.0 } | |
35 | XYPoint { x: 1.1; y: 3.2 } |
|
35 | XYPoint { x: 1.1; y: 3.2 } | |
36 | XYPoint { x: 1.9; y: 2.4 } |
|
36 | XYPoint { x: 1.9; y: 2.4 } | |
37 | XYPoint { x: 2.1; y: 2.1 } |
|
37 | XYPoint { x: 2.1; y: 2.1 } | |
@@ -39,10 +39,6 Rectangle { | |||||
39 | XYPoint { x: 3.4; y: 2.3 } |
|
39 | XYPoint { x: 3.4; y: 2.3 } | |
40 | XYPoint { x: 4.1; y: 3.1 } |
|
40 | XYPoint { x: 4.1; y: 3.1 } | |
41 | } |
|
41 | } | |
42 |
|
||||
43 | Component.onCompleted: { |
|
|||
44 | createDefaultAxes(); |
|
|||
45 | } |
|
|||
46 | } |
|
42 | } | |
47 | //![1] |
|
43 | //![1] | |
48 | } |
|
44 | } |
@@ -29,15 +29,15 Rectangle { | |||||
29 | title: "NHL All-Star Team Players" |
|
29 | title: "NHL All-Star Team Players" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 |
|
31 | |||
32 |
|
|
32 | BarCategoriesAxis { | |
33 | //TODO: obsolate |
|
33 | id: catergoriesAxis | |
34 | //axisX: CategoriesAxis { |
|
34 | categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", | |
35 | // id: categoriesAxis |
|
35 | "2009", "2010", "2011" ] | |
36 | // categories: ["2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", |
|
36 | } | |
37 | // "2008", "2009", "2010", "2011" ] |
|
|||
38 | //} |
|
|||
39 |
|
|
37 | ||
|
38 | AreaSeries { | |||
40 | name: "Russian" |
|
39 | name: "Russian" | |
|
40 | axisX: catergoriesAxis | |||
41 | upperSeries: LineSeries { |
|
41 | upperSeries: LineSeries { | |
42 | XYPoint { x: 0; y: 1 } |
|
42 | XYPoint { x: 0; y: 1 } | |
43 | XYPoint { x: 1; y: 1 } |
|
43 | XYPoint { x: 1; y: 1 } | |
@@ -52,27 +52,13 Rectangle { | |||||
52 | XYPoint { x: 10; y: 2 } |
|
52 | XYPoint { x: 10; y: 2 } | |
53 | XYPoint { x: 11; y: 1 } |
|
53 | XYPoint { x: 11; y: 1 } | |
54 | } |
|
54 | } | |
55 | lowerSeries: LineSeries { |
|
|||
56 | XYPoint { x: 0; y: 0 } |
|
|||
57 | XYPoint { x: 1; y: 0 } |
|
|||
58 | XYPoint { x: 2; y: 0 } |
|
|||
59 | XYPoint { x: 3; y: 0 } |
|
|||
60 | XYPoint { x: 4; y: 0 } |
|
|||
61 | XYPoint { x: 5; y: 0 } |
|
|||
62 | XYPoint { x: 6; y: 0 } |
|
|||
63 | XYPoint { x: 7; y: 0 } |
|
|||
64 | XYPoint { x: 8; y: 0 } |
|
|||
65 | XYPoint { x: 9; y: 0 } |
|
|||
66 | XYPoint { x: 10; y: 0 } |
|
|||
67 | XYPoint { x: 11; y: 0 } |
|
|||
68 | } |
|
|||
69 | } |
|
55 | } | |
70 | // ... |
|
56 | // ... | |
71 | //![1] |
|
57 | //![1] | |
72 |
|
58 | |||
73 | AreaSeries { |
|
59 | AreaSeries { | |
74 | id: swedish |
|
|||
75 | name: "Swedish" |
|
60 | name: "Swedish" | |
|
61 | axisX: catergoriesAxis | |||
76 | upperSeries: LineSeries { |
|
62 | upperSeries: LineSeries { | |
77 | XYPoint { x: 0; y: 1 } |
|
63 | XYPoint { x: 0; y: 1 } | |
78 | XYPoint { x: 1; y: 1 } |
|
64 | XYPoint { x: 1; y: 1 } | |
@@ -87,28 +73,11 Rectangle { | |||||
87 | XYPoint { x: 10; y: 3 } |
|
73 | XYPoint { x: 10; y: 3 } | |
88 | XYPoint { x: 11; y: 3 } |
|
74 | XYPoint { x: 11; y: 3 } | |
89 | } |
|
75 | } | |
90 | lowerSeries: LineSeries { |
|
|||
91 | XYPoint { x: 0; y: 0 } |
|
|||
92 | XYPoint { x: 1; y: 0 } |
|
|||
93 | XYPoint { x: 2; y: 0 } |
|
|||
94 | XYPoint { x: 3; y: 0 } |
|
|||
95 | XYPoint { x: 4; y: 0 } |
|
|||
96 | XYPoint { x: 5; y: 0 } |
|
|||
97 | XYPoint { x: 6; y: 0 } |
|
|||
98 | XYPoint { x: 7; y: 0 } |
|
|||
99 | XYPoint { x: 8; y: 0 } |
|
|||
100 | XYPoint { x: 9; y: 0 } |
|
|||
101 | XYPoint { x: 10; y: 0 } |
|
|||
102 | XYPoint { x: 11; y: 0 } |
|
|||
103 | } |
|
|||
104 | onClicked: { |
|
|||
105 | color = "yellow"; |
|
|||
106 | borderColor = "blue"; |
|
|||
107 | } |
|
|||
108 | } |
|
76 | } | |
109 |
|
77 | |||
110 | AreaSeries { |
|
78 | AreaSeries { | |
111 | name: "Finnish" |
|
79 | name: "Finnish" | |
|
80 | axisX: catergoriesAxis | |||
112 | upperSeries: LineSeries { |
|
81 | upperSeries: LineSeries { | |
113 | XYPoint { x: 0; y: 0 } |
|
82 | XYPoint { x: 0; y: 0 } | |
114 | XYPoint { x: 1; y: 0 } |
|
83 | XYPoint { x: 1; y: 0 } | |
@@ -123,27 +92,10 Rectangle { | |||||
123 | XYPoint { x: 10; y: 0 } |
|
92 | XYPoint { x: 10; y: 0 } | |
124 | XYPoint { x: 11; y: 1 } |
|
93 | XYPoint { x: 11; y: 1 } | |
125 | } |
|
94 | } | |
126 | lowerSeries: LineSeries { |
|
|||
127 | XYPoint { x: 0; y: 0 } |
|
|||
128 | XYPoint { x: 1; y: 0 } |
|
|||
129 | XYPoint { x: 2; y: 0 } |
|
|||
130 | XYPoint { x: 3; y: 0 } |
|
|||
131 | XYPoint { x: 4; y: 0 } |
|
|||
132 | XYPoint { x: 5; y: 0 } |
|
|||
133 | XYPoint { x: 6; y: 0 } |
|
|||
134 | XYPoint { x: 7; y: 0 } |
|
|||
135 | XYPoint { x: 8; y: 0 } |
|
|||
136 | XYPoint { x: 9; y: 0 } |
|
|||
137 | XYPoint { x: 10; y: 0 } |
|
|||
138 | XYPoint { x: 11; y: 0 } |
|
|||
139 | } |
|
|||
140 | onClicked: { |
|
95 | onClicked: { | |
141 | color = "white"; |
|
96 | color = "white"; | |
142 | borderColor = "blue"; |
|
97 | borderColor = "blue"; | |
143 | } |
|
98 | } | |
144 | } |
|
99 | } | |
145 | Component.onCompleted: { |
|
|||
146 | createDefaultAxes(); |
|
|||
147 | } |
|
|||
148 | } |
|
100 | } | |
149 | } |
|
101 | } |
@@ -51,13 +51,6 Rectangle { | |||||
51 | XYPoint { x: 2.2; y: 2.9 } |
|
51 | XYPoint { x: 2.2; y: 2.9 } | |
52 | XYPoint { x: 2.4; y: 2.7 } |
|
52 | XYPoint { x: 2.4; y: 2.7 } | |
53 | XYPoint { x: 2.67; y: 2.65 } |
|
53 | XYPoint { x: 2.67; y: 2.65 } | |
54 | //![2] |
|
|||
55 |
|
|
54 | } | |
56 |
|
||||
57 | Component.onCompleted: { |
|
|||
58 | createDefaultAxes(); |
|
|||
59 | } |
|
|||
60 |
|
||||
61 | } |
|
55 | } | |
62 | //![2] |
|
|||
63 | } |
|
56 | } |
@@ -29,20 +29,14 Rectangle { | |||||
29 | title: "Bar series" |
|
29 | title: "Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id:myAxis |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | BarSeries { |
|
33 | BarSeries { | |
37 |
id: mySeries |
|
34 | id: mySeries | |
|
35 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |||
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
39 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisX(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
40 | } | |
47 | //![1] |
|
41 | //![1] | |
48 | } |
|
42 | } |
@@ -29,20 +29,14 Rectangle { | |||||
29 | title: "Stacked Bar series" |
|
29 | title: "Stacked Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id: myAxis; |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | StackedBarSeries { |
|
33 | StackedBarSeries { | |
37 |
id: mySeries |
|
34 | id: mySeries | |
|
35 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |||
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
36 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
37 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
38 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
39 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisX(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
40 | } | |
47 | //![1] |
|
41 | //![1] | |
48 | } |
|
42 | } |
@@ -29,21 +29,13 Rectangle { | |||||
29 | title: "Percent Bar series" |
|
29 | title: "Percent Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id: myAxis |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | PercentBarSeries { |
|
33 | PercentBarSeries { | |
37 | id: mySeries |
|
34 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
38 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisX(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
39 | } | |
47 | //![1] |
|
40 | //![1] | |
48 | } |
|
41 | } | |
49 |
|
@@ -29,20 +29,13 Rectangle { | |||||
29 | title: "Horizontal Bar series" |
|
29 | title: "Horizontal Bar series" | |
30 | anchors.fill: parent |
|
30 | anchors.fill: parent | |
31 | legend.alignment: Qt.AlignBottom |
|
31 | legend.alignment: Qt.AlignBottom | |
32 | BarCategoriesAxis { |
|
32 | ||
33 | id: myAxis |
|
|||
34 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
35 | } |
|
|||
36 | HorizontalBarSeries { |
|
33 | HorizontalBarSeries { | |
37 | id: mySeries |
|
34 | axisY: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } |
|
35 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] } | |
39 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } |
|
36 | BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } | |
40 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } |
|
37 | BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } | |
41 | } |
|
38 | } | |
42 | Component.onCompleted: { |
|
|||
43 | createDefaultAxes(); |
|
|||
44 | setAxisY(myAxis,mySeries); |
|
|||
45 | } |
|
|||
46 | } |
|
39 | } | |
47 | //![1] |
|
40 | //![1] | |
48 | } |
|
41 | } |
@@ -27,7 +27,6 Rectangle { | |||||
27 | property int __activeIndex: 1 |
|
27 | property int __activeIndex: 1 | |
28 | property real __intervalCoefficient: 0 |
|
28 | property real __intervalCoefficient: 0 | |
29 |
|
29 | |||
30 |
|
||||
31 | //![1] |
|
30 | //![1] | |
32 | ChartView { |
|
31 | ChartView { | |
33 | id: chartView |
|
32 | id: chartView | |
@@ -62,7 +61,6 Rectangle { | |||||
62 | interval = __intervalCoefficient * j * j; |
|
61 | interval = __intervalCoefficient * j * j; | |
63 | splineSeries.append(j, interval); |
|
62 | splineSeries.append(j, interval); | |
64 | } |
|
63 | } | |
65 | chartView.createDefaultAxes() |
|
|||
66 | chartView.axisX(scatterSeries).max = j; |
|
64 | chartView.axisX(scatterSeries).max = j; | |
67 | chartView.axisY(scatterSeries).max = 1000; |
|
65 | chartView.axisY(scatterSeries).max = 1000; | |
68 | } |
|
66 | } |
@@ -33,12 +33,14 Rectangle { | |||||
33 | animationOptions: ChartView.SeriesAnimations |
|
33 | animationOptions: ChartView.SeriesAnimations | |
34 |
|
34 | |||
35 | BarCategoriesAxis { |
|
35 | BarCategoriesAxis { | |
36 |
id: categor |
|
36 | id: categoriesAxis | |
37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ] |
|
37 | categories: ["2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014" ] | |
|
38 | min: "2007" | |||
|
39 | max: "2014" | |||
38 | } |
|
40 | } | |
39 |
|
41 | |||
40 | ValuesAxis { |
|
42 | ValuesAxis { | |
41 |
id: |
|
43 | id: valuesAxis | |
42 | min: 0 |
|
44 | min: 0 | |
43 | max: 60 |
|
45 | max: 60 | |
44 | } |
|
46 | } | |
@@ -63,6 +65,8 Rectangle { | |||||
63 | BarSeries { |
|
65 | BarSeries { | |
64 | id: myBarSeries |
|
66 | id: myBarSeries | |
65 | name: "Others" |
|
67 | name: "Others" | |
|
68 | axisX: categoriesAxis | |||
|
69 | axisY: valuesAxis | |||
66 | barWidth: 0.9 |
|
70 | barWidth: 0.9 | |
67 | visible: false |
|
71 | visible: false | |
68 | HBarModelMapper { |
|
72 | HBarModelMapper { | |
@@ -78,6 +82,8 Rectangle { | |||||
78 | LineSeries { |
|
82 | LineSeries { | |
79 | id: lineSeries1 |
|
83 | id: lineSeries1 | |
80 | name: "Volkswagen" |
|
84 | name: "Volkswagen" | |
|
85 | axisX: categoriesAxis | |||
|
86 | axisY: valuesAxis | |||
81 | visible: false |
|
87 | visible: false | |
82 | HXYModelMapper { |
|
88 | HXYModelMapper { | |
83 | model: customModel |
|
89 | model: customModel | |
@@ -91,6 +97,8 Rectangle { | |||||
91 | LineSeries { |
|
97 | LineSeries { | |
92 | id: lineSeries2 |
|
98 | id: lineSeries2 | |
93 | name: "Toyota" |
|
99 | name: "Toyota" | |
|
100 | axisX: categoriesAxis | |||
|
101 | axisY: valuesAxis | |||
94 | visible: false |
|
102 | visible: false | |
95 | HXYModelMapper { |
|
103 | HXYModelMapper { | |
96 | model: customModel |
|
104 | model: customModel | |
@@ -103,6 +111,8 Rectangle { | |||||
103 | LineSeries { |
|
111 | LineSeries { | |
104 | id: lineSeries3 |
|
112 | id: lineSeries3 | |
105 | name: "Ford" |
|
113 | name: "Ford" | |
|
114 | axisX: categoriesAxis | |||
|
115 | axisY: valuesAxis | |||
106 | visible: false |
|
116 | visible: false | |
107 | HXYModelMapper { |
|
117 | HXYModelMapper { | |
108 | model: customModel |
|
118 | model: customModel | |
@@ -115,6 +125,8 Rectangle { | |||||
115 | LineSeries { |
|
125 | LineSeries { | |
116 | id: lineSeries4 |
|
126 | id: lineSeries4 | |
117 | name: "Skoda" |
|
127 | name: "Skoda" | |
|
128 | axisX: categoriesAxis | |||
|
129 | axisY: valuesAxis | |||
118 | visible: false |
|
130 | visible: false | |
119 | HXYModelMapper { |
|
131 | HXYModelMapper { | |
120 | model: customModel |
|
132 | model: customModel | |
@@ -127,6 +139,8 Rectangle { | |||||
127 | LineSeries { |
|
139 | LineSeries { | |
128 | id: lineSeries5 |
|
140 | id: lineSeries5 | |
129 | name: "Volvo" |
|
141 | name: "Volvo" | |
|
142 | axisX: categoriesAxis | |||
|
143 | axisY: valuesAxis | |||
130 | visible: false |
|
144 | visible: false | |
131 | HXYModelMapper { |
|
145 | HXYModelMapper { | |
132 | model: customModel |
|
146 | model: customModel | |
@@ -162,23 +176,5 Rectangle { | |||||
162 | } |
|
176 | } | |
163 | } |
|
177 | } | |
164 | //![3] |
|
178 | //![3] | |
165 |
|
||||
166 | Component.onCompleted: { |
|
|||
167 | setAxisX(categoryAxis,myBarSeries) |
|
|||
168 | setAxisX(categoryAxis,lineSeries1) |
|
|||
169 | setAxisX(categoryAxis,lineSeries2) |
|
|||
170 | setAxisX(categoryAxis,lineSeries3) |
|
|||
171 | setAxisX(categoryAxis,lineSeries4) |
|
|||
172 | setAxisX(categoryAxis,lineSeries5) |
|
|||
173 | setAxisY(yAxis,myBarSeries) |
|
|||
174 | setAxisY(yAxis,lineSeries1) |
|
|||
175 | setAxisY(yAxis,lineSeries2) |
|
|||
176 | setAxisY(yAxis,lineSeries3) |
|
|||
177 | setAxisY(yAxis,lineSeries4) |
|
|||
178 | setAxisY(yAxis,lineSeries5) |
|
|||
179 | categoryAxis.min = "2007" |
|
|||
180 | categoryAxis.max = "2014" |
|
|||
181 | categoryAxis.visible = true; |
|
|||
182 | } |
|
|||
183 | } |
|
179 | } | |
184 | } |
|
180 | } |
@@ -63,26 +63,24 Rectangle { | |||||
63 | var lineSeries = chartView.series(speedsXml.get(currentIndex).driver); |
|
63 | var lineSeries = chartView.series(speedsXml.get(currentIndex).driver); | |
64 | if (!lineSeries){ |
|
64 | if (!lineSeries) { | |
65 | lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver); |
|
65 | lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver); | |
66 |
chartView. |
|
66 | chartView.axisY().min = 0; | |
67 |
chartView.axisY( |
|
67 | chartView.axisY().max = 250 | |
68 | chartView.axisY(lineSeries).max = 250 |
|
|||
69 | } |
|
68 | } | |
70 |
|
||||
71 | lineSeries.append(currentIndex, speedsXml.get(currentIndex).speed); |
|
69 | lineSeries.append(currentIndex, speedsXml.get(currentIndex).speed); | |
72 |
|
70 | |||
73 | // Make the x-axis range dynamic |
|
71 | // Make the x-axis range dynamic | |
74 | if (currentIndex > 9) |
|
72 | if (currentIndex > 9) | |
75 |
chartView.axisX( |
|
73 | chartView.axisX().min = currentIndex - 10; | |
76 | else |
|
74 | else | |
77 |
chartView.axisX( |
|
75 | chartView.axisX().min = 0; | |
78 |
|
76 | |||
79 |
chartView.axisX( |
|
77 | chartView.axisX().max = currentIndex + 1; | |
80 | } else { |
|
78 | } else { | |
81 | // No more data, change x-axis range to show all the data |
|
79 | // No more data, change x-axis range to show all the data | |
82 | timer.stop(); |
|
80 | timer.stop(); | |
83 | chartView.animationOptions = ChartView.AllAnimations; |
|
81 | chartView.animationOptions = ChartView.AllAnimations; | |
84 |
chartView.axisX( |
|
82 | chartView.axisX().min = 0; | |
85 |
chartView.axisX( |
|
83 | chartView.axisX().max = currentIndex + 1; | |
86 | } |
|
84 | } | |
87 | } |
|
85 | } | |
88 | } |
|
86 | } |
@@ -40,17 +40,14 ChartView { | |||||
40 | LineSeries { |
|
40 | LineSeries { | |
41 | id: lineSeries1 |
|
41 | id: lineSeries1 | |
42 | name: "signal 1" |
|
42 | name: "signal 1" | |
|
43 | axisX: axisX | |||
|
44 | axisY: axisY | |||
43 | } |
|
45 | } | |
44 | LineSeries { |
|
46 | LineSeries { | |
45 | id: lineSeries2 |
|
47 | id: lineSeries2 | |
46 | name: "signal 2" |
|
48 | name: "signal 2" | |
47 | } |
|
49 | axisX: axisX | |
48 |
|
50 | axisY: axisY | ||
49 | Component.onCompleted: { |
|
|||
50 | chartView.setAxisX(axisX, lineSeries1); |
|
|||
51 | chartView.setAxisY(axisY, lineSeries1); |
|
|||
52 | chartView.setAxisX(axisX, lineSeries2); |
|
|||
53 | chartView.setAxisY(axisY, lineSeries2); |
|
|||
54 | } |
|
51 | } | |
55 |
|
52 | |||
56 | Timer { |
|
53 | Timer { | |
@@ -79,8 +76,8 ChartView { | |||||
79 | series.markerSize = 3; |
|
76 | series.markerSize = 3; | |
80 | series.borderColor = "transparent"; |
|
77 | series.borderColor = "transparent"; | |
81 | } |
|
78 | } | |
82 |
|
|
79 | // chartView.setAxisX(axisX, series); | |
83 |
|
|
80 | // chartView.setAxisY(axisY, series); | |
84 | } |
|
81 | } | |
85 | } |
|
82 | } | |
86 |
|
83 | |||
@@ -92,7 +89,6 ChartView { | |||||
92 | } |
|
89 | } | |
93 |
|
90 | |||
94 | function changeRefreshRate(rate) { |
|
91 | function changeRefreshRate(rate) { | |
95 | console.log("rate " + rate); |
|
|||
96 | refreshTimer.interval = 1 / Number(rate) * 1000; |
|
92 | refreshTimer.interval = 1 / Number(rate) * 1000; | |
97 | } |
|
93 | } | |
98 | } |
|
94 | } |
@@ -38,12 +38,13 Rectangle { | |||||
38 |
|
38 | |||
39 | //![2] |
|
39 | //![2] | |
40 | BarCategoriesAxis { |
|
40 | BarCategoriesAxis { | |
41 |
|
|
41 | id: barCategoriesAxis | |
42 | categories: ["Mo", "Tu", "We", "Th", "Fr"] |
|
|||
43 | } |
|
42 | } | |
44 |
|
43 | |||
45 | BarSeries { |
|
44 | BarSeries { | |
46 | id: myBarSeries |
|
45 | id: myBarSeries | |
|
46 | axisX: barCategoriesAxis | |||
|
47 | axisY: valuesAxisY | |||
47 | BarSet { |
|
48 | BarSet { | |
48 | id: rainfallSet |
|
49 | id: rainfallSet | |
49 | label: "Rainfall" |
|
50 | label: "Rainfall" | |
@@ -51,30 +52,31 Rectangle { | |||||
51 | } |
|
52 | } | |
52 |
|
53 | |||
53 | ValuesAxis{ |
|
54 | ValuesAxis { | |
54 |
id: |
|
55 | id: valuesAxisX | |
|
56 | min: 0 | |||
|
57 | max: 5 | |||
|
58 | } | |||
|
59 | ||||
|
60 | ValuesAxis{ | |||
|
61 | id: valuesAxisY | |||
55 | min: 0 |
|
62 | min: 0 | |
56 | max: 10 |
|
63 | max: 10 | |
57 | } |
|
64 | } | |
58 |
|
65 | |||
59 | LineSeries { |
|
66 | LineSeries { | |
60 | id: maxTempSeries |
|
67 | id: maxTempSeries | |
|
68 | axisX: valuesAxisX | |||
|
69 | axisY: valuesAxisY | |||
61 | name: "Max. temperature" |
|
70 | name: "Max. temperature" | |
62 | } |
|
71 | } | |
63 |
|
72 | |||
64 | LineSeries { |
|
73 | LineSeries { | |
65 | id: minTempSeries |
|
74 | id: minTempSeries | |
|
75 | axisX: valuesAxisX | |||
|
76 | axisY: valuesAxisY | |||
66 | name: "Min. temperature" |
|
77 | name: "Min. temperature" | |
67 | } |
|
78 | } | |
68 | //![2] |
|
79 | //![2] | |
69 |
|
||||
70 | Component.onCompleted: { |
|
|||
71 | setAxisX(myBarCategoryAxis,myBarSeries) |
|
|||
72 | setAxisX(myBarCategoryAxis,maxTempSeries) |
|
|||
73 | setAxisX(myBarCategoryAxis,minTempSeries) |
|
|||
74 | setAxisY(myValuesAxisY,maxTempSeries) |
|
|||
75 | setAxisY(myValuesAxisY,minTempSeries) |
|
|||
76 | setAxisY(myValuesAxisY,myBarSeries) |
|
|||
77 | } |
|
|||
78 | } |
|
80 | } | |
79 |
|
81 | |||
80 | // A timer to refresh the forecast every 5 minutes |
|
82 | // A timer to refresh the forecast every 5 minutes | |
@@ -100,7 +102,7 Rectangle { | |||||
100 | xhr.send(); |
|
102 | xhr.send(); | |
101 | //![3] |
|
103 | //![3] | |
102 | } else { |
|
104 | } else { | |
103 | // No app key for worldweatheronline.com given by the user -> use static data |
|
105 | // No app key for worldweatheronline.com given by the user -> use dummy static data | |
104 | var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}"; |
|
106 | var responseText = "{ \"data\": { \"current_condition\": [ {\"cloudcover\": \"10\", \"humidity\": \"61\", \"observation_time\": \"06:26 AM\", \"precipMM\": \"0.0\", \"pressure\": \"1022\", \"temp_C\": \"6\", \"temp_F\": \"43\", \"visibility\": \"10\", \"weatherCode\": \"113\", \"weatherDesc\": [ {\"value\": \"Sunny\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png\" } ], \"winddir16Point\": \"SE\", \"winddirDegree\": \"140\", \"windspeedKmph\": \"7\", \"windspeedMiles\": \"4\" } ], \"request\": [ {\"query\": \"Jyvaskyla, Finland\", \"type\": \"City\" } ], \"weather\": [ {\"date\": \"2012-05-09\", \"precipMM\": \"0.4\", \"tempMaxC\": \"14\", \"tempMaxF\": \"57\", \"tempMinC\": \"7\", \"tempMinF\": \"45\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"S\", \"winddirDegree\": \"179\", \"winddirection\": \"S\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-10\", \"precipMM\": \"2.4\", \"tempMaxC\": \"13\", \"tempMaxF\": \"55\", \"tempMinC\": \"8\", \"tempMinF\": \"46\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SW\", \"winddirDegree\": \"219\", \"winddirection\": \"SW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" }, {\"date\": \"2012-05-11\", \"precipMM\": \"11.1\", \"tempMaxC\": \"15\", \"tempMaxF\": \"59\", \"tempMinC\": \"7\", \"tempMinF\": \"44\", \"weatherCode\": \"266\", \"weatherDesc\": [ {\"value\": \"Light drizzle\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0017_cloudy_with_light_rain.png\" } ], \"winddir16Point\": \"SSW\", \"winddirDegree\": \"200\", \"winddirection\": \"SSW\", \"windspeedKmph\": \"20\", \"windspeedMiles\": \"12\" }, {\"date\": \"2012-05-12\", \"precipMM\": \"2.8\", \"tempMaxC\": \"7\", \"tempMaxF\": \"44\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"317\", \"weatherDesc\": [ {\"value\": \"Light sleet\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0021_cloudy_with_sleet.png\" } ], \"winddir16Point\": \"NW\", \"winddirDegree\": \"311\", \"winddirection\": \"NW\", \"windspeedKmph\": \"24\", \"windspeedMiles\": \"15\" }, {\"date\": \"2012-05-13\", \"precipMM\": \"0.4\", \"tempMaxC\": \"6\", \"tempMaxF\": \"42\", \"tempMinC\": \"2\", \"tempMinF\": \"35\", \"weatherCode\": \"116\", \"weatherDesc\": [ {\"value\": \"Partly Cloudy\" } ], \"weatherIconUrl\": [ {\"value\": \"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0002_sunny_intervals.png\" } ], \"winddir16Point\": \"WNW\", \"winddirDegree\": \"281\", \"winddirection\": \"WNW\", \"windspeedKmph\": \"21\", \"windspeedMiles\": \"13\" } ] }}"; | |
105 | var a = JSON.parse(responseText); |
|
107 | var a = JSON.parse(responseText); | |
106 | parseWeatherData(a); |
|
108 | parseWeatherData(a); | |
@@ -156,26 +158,25 Rectangle { | |||||
156 |
|
158 | |||
157 | //![5] |
|
159 | //![5] | |
158 | // Store temperature values, rainfall and weather icon |
|
160 | // Store temperature values, rainfall and weather icon | |
159 | maxTempSeries.append(i, weatherObj.tempMaxC); |
|
161 | maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC); | |
160 | minTempSeries.append(i, weatherObj.tempMinC); |
|
162 | minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC); | |
161 | rainfallSet.append(i, weatherObj.precipMM); |
|
163 | rainfallSet.append(i, weatherObj.precipMM); | |
162 | weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value}); |
|
164 | weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value}); | |
163 | //![5] |
|
165 | //![5] | |
164 |
|
166 | |||
165 | // Update scale of the chart |
|
167 | // Update scale of the chart | |
166 |
|
|
168 | valuesAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC); | |
167 | chartView.axisY().max = Math.max(chartView.axisY().max,weatherObj.tempMinC) |
|
169 | valuesAxisX.min = 0; | |
168 | chartView.axisX().min = 0; |
|
170 | valuesAxisX.max = Number(i) + 1; | |
169 | chartView.axisX().max = i+1; |
|
|||
170 |
|
171 | |||
171 | // Set the x-axis labels to the dates of the forecast |
|
172 | // Set the x-axis labels to the dates of the forecast | |
172 |
var xLabels = |
|
173 | var xLabels = barCategoriesAxis.categories; | |
173 | xLabels[Number(i)] = weatherObj.date.substring(5, 10); |
|
174 | xLabels[Number(i)] = weatherObj.date.substring(5, 10); | |
174 |
|
|
175 | barCategoriesAxis.categories = xLabels; | |
175 |
|
|
176 | barCategoriesAxis.visible = true; | |
|
177 | barCategoriesAxis.min = 0; | |||
|
178 | barCategoriesAxis.max = xLabels.length - 1; | |||
176 | } |
|
179 | } | |
177 |
|
||||
178 |
|
||||
179 | } |
|
180 | } | |
180 |
|
181 | |||
181 | } |
|
182 | } |
@@ -4,6 +4,7 QT += declarative | |||||
4 | !include( ../plugins.pri ) { |
|
4 | !include( ../plugins.pri ) { | |
5 | error( "Couldn't find the plugins.pri file!" ) |
|
5 | error( "Couldn't find the plugins.pri file!" ) | |
6 | } |
|
6 | } | |
|
7 | INCLUDEPATH += $$CHART_BUILD_PRIVATE_HEADER_DIR | |||
7 |
|
8 | |||
8 | contains(QT_MAJOR_VERSION, 5) { |
|
9 | contains(QT_MAJOR_VERSION, 5) { | |
9 | # TODO: QtQuick2 not supported by the implementation currently |
|
10 | # TODO: QtQuick2 not supported by the implementation currently |
@@ -23,11 +23,12 | |||||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
25 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : | |
26 | QAreaSeries(parent) |
|
26 | QAreaSeries(parent), | |
|
27 | m_axisX(0), | |||
|
28 | m_axisY(0) | |||
27 | { |
|
29 | { | |
28 | } |
|
30 | } | |
29 |
|
31 | |||
30 |
|
||||
31 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series) |
|
32 | void DeclarativeAreaSeries::setUpperSeries(DeclarativeLineSeries* series) | |
32 | { |
|
33 | { | |
33 | QAreaSeries::setUpperSeries(series); |
|
34 | QAreaSeries::setUpperSeries(series); |
@@ -31,6 +31,8 class DeclarativeAreaSeries : public QAreaSeries | |||||
31 | Q_OBJECT |
|
31 | Q_OBJECT | |
32 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) |
|
32 | Q_PROPERTY(DeclarativeLineSeries *upperSeries READ upperSeries WRITE setUpperSeries) | |
33 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) |
|
33 | Q_PROPERTY(DeclarativeLineSeries *lowerSeries READ lowerSeries WRITE setLowerSeries) | |
|
34 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
35 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
34 |
|
36 | |||
35 | public: |
|
37 | public: | |
36 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
38 | explicit DeclarativeAreaSeries(QObject *parent = 0); | |
@@ -38,6 +40,18 public: | |||||
38 | DeclarativeLineSeries* upperSeries() const; |
|
40 | DeclarativeLineSeries* upperSeries() const; | |
39 | void setLowerSeries(DeclarativeLineSeries* series); |
|
41 | void setLowerSeries(DeclarativeLineSeries* series); | |
40 | DeclarativeLineSeries* lowerSeries() const; |
|
42 | DeclarativeLineSeries* lowerSeries() const; | |
|
43 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
44 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
45 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
46 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
|
47 | ||||
|
48 | Q_SIGNALS: | |||
|
49 | void axisXChanged(QAbstractAxis *axis); | |||
|
50 | void axisYChanged(QAbstractAxis *axis); | |||
|
51 | ||||
|
52 | private: | |||
|
53 | QAbstractAxis *m_axisX; | |||
|
54 | QAbstractAxis *m_axisY; | |||
41 | }; |
|
55 | }; | |
42 |
|
56 | |||
43 | QTCOMMERCIALCHART_END_NAMESPACE |
|
57 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -60,7 +60,9 void DeclarativeBarSet::setValues(QVariantList values) | |||||
60 |
|
60 | |||
61 | // Declarative bar series ====================================================================================== |
|
61 | // Declarative bar series ====================================================================================== | |
62 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : |
|
62 | DeclarativeBarSeries::DeclarativeBarSeries(QDeclarativeItem *parent) : | |
63 | QBarSeries(parent) |
|
63 | QBarSeries(parent), | |
|
64 | m_axisX(0), | |||
|
65 | m_axisY(0) | |||
64 | { |
|
66 | { | |
65 | } |
|
67 | } | |
66 |
|
68 | |||
@@ -117,7 +119,9 DeclarativeBarSet *DeclarativeBarSeries::insert(int index, QString label, QVaria | |||||
117 |
|
119 | |||
118 | // Declarative stacked bar series ============================================================================== |
|
120 | // Declarative stacked bar series ============================================================================== | |
119 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : |
|
121 | DeclarativeStackedBarSeries::DeclarativeStackedBarSeries(QDeclarativeItem *parent) : | |
120 | QStackedBarSeries(parent) |
|
122 | QStackedBarSeries(parent), | |
|
123 | m_axisX(0), | |||
|
124 | m_axisY(0) | |||
121 | { |
|
125 | { | |
122 | } |
|
126 | } | |
123 |
|
127 | |||
@@ -175,7 +179,9 DeclarativeBarSet *DeclarativeStackedBarSeries::insert(int index, QString label, | |||||
175 |
|
179 | |||
176 | // Declarative percent bar series ============================================================================== |
|
180 | // Declarative percent bar series ============================================================================== | |
177 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : |
|
181 | DeclarativePercentBarSeries::DeclarativePercentBarSeries(QDeclarativeItem *parent) : | |
178 | QPercentBarSeries(parent) |
|
182 | QPercentBarSeries(parent), | |
|
183 | m_axisX(0), | |||
|
184 | m_axisY(0) | |||
179 | { |
|
185 | { | |
180 | } |
|
186 | } | |
181 |
|
187 | |||
@@ -232,7 +238,9 DeclarativeBarSet *DeclarativePercentBarSeries::insert(int index, QString label, | |||||
232 |
|
238 | |||
233 | // Declarative horizontal bar series =========================================================================== |
|
239 | // Declarative horizontal bar series =========================================================================== | |
234 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : |
|
240 | DeclarativeHorizontalBarSeries::DeclarativeHorizontalBarSeries(QDeclarativeItem *parent) : | |
235 | QHorizontalBarSeries(parent) |
|
241 | QHorizontalBarSeries(parent), | |
|
242 | m_axisX(0), | |||
|
243 | m_axisY(0) | |||
236 | { |
|
244 | { | |
237 | } |
|
245 | } | |
238 |
|
246 | |||
@@ -289,7 +297,9 DeclarativeBarSet *DeclarativeHorizontalBarSeries::insert(int index, QString lab | |||||
289 |
|
297 | |||
290 | // Declarative horizontal stacked bar series =================================================================== |
|
298 | // Declarative horizontal stacked bar series =================================================================== | |
291 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : |
|
299 | DeclarativeHorizontalStackedBarSeries::DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent) : | |
292 | QHorizontalStackedBarSeries(parent) |
|
300 | QHorizontalStackedBarSeries(parent), | |
|
301 | m_axisX(0), | |||
|
302 | m_axisY(0) | |||
293 | { |
|
303 | { | |
294 | } |
|
304 | } | |
295 |
|
305 | |||
@@ -346,7 +356,9 DeclarativeBarSet *DeclarativeHorizontalStackedBarSeries::insert(int index, QStr | |||||
346 |
|
356 | |||
347 | // Declarative horizontal percent bar series =================================================================== |
|
357 | // Declarative horizontal percent bar series =================================================================== | |
348 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : |
|
358 | DeclarativeHorizontalPercentBarSeries::DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent) : | |
349 | QHorizontalPercentBarSeries(parent) |
|
359 | QHorizontalPercentBarSeries(parent), | |
|
360 | m_axisX(0), | |||
|
361 | m_axisY(0) | |||
350 | { |
|
362 | { | |
351 | } |
|
363 | } | |
352 |
|
364 |
@@ -63,12 +63,20 class DeclarativeBarSeries : public QBarSeries, public QDeclarativeParserStatus | |||||
63 | { |
|
63 | { | |
64 | Q_OBJECT |
|
64 | Q_OBJECT | |
65 | Q_INTERFACES(QDeclarativeParserStatus) |
|
65 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
66 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
67 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
66 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
68 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
67 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
69 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
68 |
|
70 | |||
69 | public: |
|
71 | public: | |
70 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); |
|
72 | explicit DeclarativeBarSeries(QDeclarativeItem *parent = 0); | |
|
73 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
74 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
75 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
76 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
71 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
77 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
78 | ||||
|
79 | public: | |||
72 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
80 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
73 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
81 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
74 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
82 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -79,6 +87,10 public: // from QDeclarativeParserStatus | |||||
79 | void classBegin(); |
|
87 | void classBegin(); | |
80 | void componentComplete(); |
|
88 | void componentComplete(); | |
81 |
|
89 | |||
|
90 | Q_SIGNALS: | |||
|
91 | void axisXChanged(QAbstractAxis *axis); | |||
|
92 | void axisYChanged(QAbstractAxis *axis); | |||
|
93 | ||||
82 | public Q_SLOTS: |
|
94 | public Q_SLOTS: | |
83 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
95 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
84 |
|
96 | |||
@@ -91,12 +103,20 class DeclarativeStackedBarSeries : public QStackedBarSeries, public QDeclarativ | |||||
91 | { |
|
103 | { | |
92 | Q_OBJECT |
|
104 | Q_OBJECT | |
93 | Q_INTERFACES(QDeclarativeParserStatus) |
|
105 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
106 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
107 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
94 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
108 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
95 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
109 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
96 |
|
110 | |||
97 | public: |
|
111 | public: | |
98 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); |
|
112 | explicit DeclarativeStackedBarSeries(QDeclarativeItem *parent = 0); | |
|
113 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
114 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
115 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
116 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
99 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
117 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
118 | ||||
|
119 | public: | |||
100 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
120 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
101 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
121 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
102 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
122 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -107,21 +127,36 public: // from QDeclarativeParserStatus | |||||
107 | void classBegin(); |
|
127 | void classBegin(); | |
108 | void componentComplete(); |
|
128 | void componentComplete(); | |
109 |
|
129 | |||
|
130 | Q_SIGNALS: | |||
|
131 | void axisXChanged(QAbstractAxis *axis); | |||
|
132 | void axisYChanged(QAbstractAxis *axis); | |||
|
133 | ||||
110 | public Q_SLOTS: |
|
134 | public Q_SLOTS: | |
111 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
135 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
112 |
|
136 | |||
|
137 | private: | |||
|
138 | QAbstractAxis* m_axisX; | |||
|
139 | QAbstractAxis* m_axisY; | |||
113 | }; |
|
140 | }; | |
114 |
|
141 | |||
115 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus |
|
142 | class DeclarativePercentBarSeries : public QPercentBarSeries, public QDeclarativeParserStatus | |
116 | { |
|
143 | { | |
117 | Q_OBJECT |
|
144 | Q_OBJECT | |
118 | Q_INTERFACES(QDeclarativeParserStatus) |
|
145 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
146 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
147 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
119 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
148 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
120 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
149 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
121 |
|
150 | |||
122 | public: |
|
151 | public: | |
123 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); |
|
152 | explicit DeclarativePercentBarSeries(QDeclarativeItem *parent = 0); | |
|
153 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
154 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
155 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
156 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
124 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
157 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
158 | ||||
|
159 | public: | |||
125 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
160 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
126 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
161 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
127 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
162 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -132,20 +167,36 public: // from QDeclarativeParserStatus | |||||
132 | void classBegin(); |
|
167 | void classBegin(); | |
133 | void componentComplete(); |
|
168 | void componentComplete(); | |
134 |
|
169 | |||
|
170 | Q_SIGNALS: | |||
|
171 | void axisXChanged(QAbstractAxis *axis); | |||
|
172 | void axisYChanged(QAbstractAxis *axis); | |||
|
173 | ||||
135 | public Q_SLOTS: |
|
174 | public Q_SLOTS: | |
136 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
175 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
176 | ||||
|
177 | private: | |||
|
178 | QAbstractAxis* m_axisX; | |||
|
179 | QAbstractAxis* m_axisY; | |||
137 | }; |
|
180 | }; | |
138 |
|
181 | |||
139 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus |
|
182 | class DeclarativeHorizontalBarSeries : public QHorizontalBarSeries, public QDeclarativeParserStatus | |
140 | { |
|
183 | { | |
141 | Q_OBJECT |
|
184 | Q_OBJECT | |
142 | Q_INTERFACES(QDeclarativeParserStatus) |
|
185 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
186 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
187 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
143 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
188 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
144 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
189 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
145 |
|
190 | |||
146 | public: |
|
191 | public: | |
147 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); |
|
192 | explicit DeclarativeHorizontalBarSeries(QDeclarativeItem *parent = 0); | |
|
193 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
194 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
195 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
196 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
148 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
197 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
198 | ||||
|
199 | public: | |||
149 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
200 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
150 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
201 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
151 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
202 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -156,20 +207,36 public: // from QDeclarativeParserStatus | |||||
156 | void classBegin(); |
|
207 | void classBegin(); | |
157 | void componentComplete(); |
|
208 | void componentComplete(); | |
158 |
|
209 | |||
|
210 | Q_SIGNALS: | |||
|
211 | void axisXChanged(QAbstractAxis *axis); | |||
|
212 | void axisYChanged(QAbstractAxis *axis); | |||
|
213 | ||||
159 | public Q_SLOTS: |
|
214 | public Q_SLOTS: | |
160 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
215 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
216 | ||||
|
217 | private: | |||
|
218 | QAbstractAxis* m_axisX; | |||
|
219 | QAbstractAxis* m_axisY; | |||
161 | }; |
|
220 | }; | |
162 |
|
221 | |||
163 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus |
|
222 | class DeclarativeHorizontalStackedBarSeries : public QHorizontalStackedBarSeries, public QDeclarativeParserStatus | |
164 | { |
|
223 | { | |
165 | Q_OBJECT |
|
224 | Q_OBJECT | |
166 | Q_INTERFACES(QDeclarativeParserStatus) |
|
225 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
226 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
227 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
167 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
228 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
168 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
229 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
169 |
|
230 | |||
170 | public: |
|
231 | public: | |
171 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); |
|
232 | explicit DeclarativeHorizontalStackedBarSeries(QDeclarativeItem *parent = 0); | |
|
233 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
234 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
235 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
236 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
172 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
237 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
238 | ||||
|
239 | public: | |||
173 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
240 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
174 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
241 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
175 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
242 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -180,20 +247,36 public: // from QDeclarativeParserStatus | |||||
180 | void classBegin(); |
|
247 | void classBegin(); | |
181 | void componentComplete(); |
|
248 | void componentComplete(); | |
182 |
|
249 | |||
|
250 | Q_SIGNALS: | |||
|
251 | void axisXChanged(QAbstractAxis *axis); | |||
|
252 | void axisYChanged(QAbstractAxis *axis); | |||
|
253 | ||||
183 | public Q_SLOTS: |
|
254 | public Q_SLOTS: | |
184 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
255 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
256 | ||||
|
257 | private: | |||
|
258 | QAbstractAxis* m_axisX; | |||
|
259 | QAbstractAxis* m_axisY; | |||
185 | }; |
|
260 | }; | |
186 |
|
261 | |||
187 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus |
|
262 | class DeclarativeHorizontalPercentBarSeries : public QHorizontalPercentBarSeries, public QDeclarativeParserStatus | |
188 | { |
|
263 | { | |
189 | Q_OBJECT |
|
264 | Q_OBJECT | |
190 | Q_INTERFACES(QDeclarativeParserStatus) |
|
265 | Q_INTERFACES(QDeclarativeParserStatus) | |
|
266 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
267 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
191 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) |
|
268 | Q_PROPERTY(QDeclarativeListProperty<QObject> seriesChildren READ seriesChildren) | |
192 | Q_CLASSINFO("DefaultProperty", "seriesChildren") |
|
269 | Q_CLASSINFO("DefaultProperty", "seriesChildren") | |
193 |
|
270 | |||
194 | public: |
|
271 | public: | |
195 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); |
|
272 | explicit DeclarativeHorizontalPercentBarSeries(QDeclarativeItem *parent = 0); | |
|
273 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
274 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
275 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
276 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
196 | QDeclarativeListProperty<QObject> seriesChildren(); |
|
277 | QDeclarativeListProperty<QObject> seriesChildren(); | |
|
278 | ||||
|
279 | public: | |||
197 | Q_INVOKABLE DeclarativeBarSet *at(int index); |
|
280 | Q_INVOKABLE DeclarativeBarSet *at(int index); | |
198 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } |
|
281 | Q_INVOKABLE DeclarativeBarSet *append(QString label, QVariantList values) { return insert(count(), label, values); } | |
199 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); |
|
282 | Q_INVOKABLE DeclarativeBarSet *insert(int index, QString label, QVariantList values); | |
@@ -204,8 +287,16 public: // from QDeclarativeParserStatus | |||||
204 | void classBegin(); |
|
287 | void classBegin(); | |
205 | void componentComplete(); |
|
288 | void componentComplete(); | |
206 |
|
289 | |||
|
290 | Q_SIGNALS: | |||
|
291 | void axisXChanged(QAbstractAxis *axis); | |||
|
292 | void axisYChanged(QAbstractAxis *axis); | |||
|
293 | ||||
207 | public Q_SLOTS: |
|
294 | public Q_SLOTS: | |
208 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
295 | static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
|
296 | ||||
|
297 | private: | |||
|
298 | QAbstractAxis* m_axisX; | |||
|
299 | QAbstractAxis* m_axisY; | |||
209 | }; |
|
300 | }; | |
210 |
|
301 | |||
211 | QTCOMMERCIALCHART_END_NAMESPACE |
|
302 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -20,6 +20,7 | |||||
20 |
|
20 | |||
21 | #include "declarativechart.h" |
|
21 | #include "declarativechart.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
|
23 | #include <QDeclarativeEngine> | |||
23 | #include "declarativelineseries.h" |
|
24 | #include "declarativelineseries.h" | |
24 | #include "declarativeareaseries.h" |
|
25 | #include "declarativeareaseries.h" | |
25 | #include "declarativebarseries.h" |
|
26 | #include "declarativebarseries.h" | |
@@ -27,6 +28,10 | |||||
27 | #include "declarativesplineseries.h" |
|
28 | #include "declarativesplineseries.h" | |
28 | #include "declarativescatterseries.h" |
|
29 | #include "declarativescatterseries.h" | |
29 | #include "qbarcategoryaxis.h" |
|
30 | #include "qbarcategoryaxis.h" | |
|
31 | #include "qvalueaxis.h" | |||
|
32 | #include "qdatetimeaxis.h" | |||
|
33 | #include "qintervalsaxis.h" | |||
|
34 | #include "qabstractseries_p.h" | |||
30 |
|
35 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
37 | |||
@@ -165,25 +170,25 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
165 | /*! |
|
170 | /*! | |
166 | \qmlmethod ChartView::scrollLeft(real pixels) |
|
171 | \qmlmethod ChartView::scrollLeft(real pixels) | |
167 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. |
|
172 | Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. | |
168 |
\sa Value |
|
173 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
169 | */ |
|
174 | */ | |
170 |
|
175 | |||
171 | /*! |
|
176 | /*! | |
172 | \qmlmethod ChartView::scrollRight(real pixels) |
|
177 | \qmlmethod ChartView::scrollRight(real pixels) | |
173 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. |
|
178 | Scrolls to right by \a pixels. This is a convenience function that suits for example for key navigation. | |
174 |
\sa Value |
|
179 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
175 | */ |
|
180 | */ | |
176 |
|
181 | |||
177 | /*! |
|
182 | /*! | |
178 | \qmlmethod ChartView::scrollUp(real pixels) |
|
183 | \qmlmethod ChartView::scrollUp(real pixels) | |
179 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. |
|
184 | Scrolls up by \a pixels. This is a convenience function that suits for example for key navigation. | |
180 |
\sa Value |
|
185 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
181 | */ |
|
186 | */ | |
182 |
|
187 | |||
183 | /*! |
|
188 | /*! | |
184 | \qmlmethod ChartView::scrollDown(real pixels) |
|
189 | \qmlmethod ChartView::scrollDown(real pixels) | |
185 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. |
|
190 | Scrolls down by \a pixels. This is a convenience function that suits for example for key navigation. | |
186 |
\sa Value |
|
191 | \sa ValueAxis::min, ValueAxis::max, BarCategoriesAxis::min, BarCategoriesAxis::max | |
187 | */ |
|
192 | */ | |
188 |
|
193 | |||
189 | /*! |
|
194 | /*! | |
@@ -252,16 +257,96 void DeclarativeChart::componentComplete() | |||||
252 | { |
|
257 | { | |
253 | foreach(QObject *child, children()) { |
|
258 | foreach(QObject *child, children()) { | |
254 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
259 | if (qobject_cast<QAbstractSeries *>(child)) { | |
255 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
|||
256 | // TODO: how about optional y-axis? |
|
|||
257 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
260 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); | |
|
261 | if (qobject_cast<DeclarativeLineSeries *>(child)) { | |||
|
262 | DeclarativeLineSeries *s = qobject_cast<DeclarativeLineSeries *>(child); | |||
|
263 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
264 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
265 | setAxisX(s->axisX(), s); | |||
|
266 | setAxisY(s->axisY(), s); | |||
|
267 | } else if (qobject_cast<DeclarativeSplineSeries *>(child)) { | |||
|
268 | DeclarativeSplineSeries *s = qobject_cast<DeclarativeSplineSeries *>(child); | |||
|
269 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
270 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
271 | setAxisX(s->axisX(), s); | |||
|
272 | setAxisY(s->axisY(), s); | |||
|
273 | } else if (qobject_cast<DeclarativeScatterSeries *>(child)) { | |||
|
274 | DeclarativeScatterSeries *s = qobject_cast<DeclarativeScatterSeries *>(child); | |||
|
275 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
276 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
277 | setAxisX(s->axisX(), s); | |||
|
278 | setAxisY(s->axisY(), s); | |||
|
279 | } else if (qobject_cast<DeclarativeAreaSeries *>(child)) { | |||
|
280 | DeclarativeAreaSeries *s = qobject_cast<DeclarativeAreaSeries *>(child); | |||
|
281 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
282 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
283 | setAxisX(s->axisX(), s); | |||
|
284 | setAxisY(s->axisY(), s); | |||
|
285 | } else if (qobject_cast<DeclarativeBarSeries *>(child)) { | |||
|
286 | DeclarativeBarSeries *s = qobject_cast<DeclarativeBarSeries *>(child); | |||
|
287 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
288 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
289 | setAxisX(s->axisX(), s); | |||
|
290 | setAxisY(s->axisY(), s); | |||
|
291 | } else if (qobject_cast<DeclarativeStackedBarSeries *>(child)) { | |||
|
292 | DeclarativeStackedBarSeries *s = qobject_cast<DeclarativeStackedBarSeries *>(child); | |||
|
293 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
294 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
295 | setAxisX(s->axisX(), s); | |||
|
296 | setAxisY(s->axisY(), s); | |||
|
297 | } else if (qobject_cast<DeclarativePercentBarSeries *>(child)) { | |||
|
298 | DeclarativePercentBarSeries *s = qobject_cast<DeclarativePercentBarSeries *>(child); | |||
|
299 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
300 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
301 | setAxisX(s->axisX(), s); | |||
|
302 | setAxisY(s->axisY(), s); | |||
|
303 | } else if (qobject_cast<DeclarativeHorizontalBarSeries *>(child)) { | |||
|
304 | DeclarativeHorizontalBarSeries *s = qobject_cast<DeclarativeHorizontalBarSeries *>(child); | |||
|
305 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
306 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
307 | setAxisX(s->axisX(), s); | |||
|
308 | setAxisY(s->axisY(), s); | |||
|
309 | } else if (qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child)) { | |||
|
310 | DeclarativeHorizontalStackedBarSeries *s = qobject_cast<DeclarativeHorizontalStackedBarSeries *>(child); | |||
|
311 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
312 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
313 | setAxisX(s->axisX(), s); | |||
|
314 | setAxisY(s->axisY(), s); | |||
|
315 | } else if (qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child)) { | |||
|
316 | DeclarativeHorizontalPercentBarSeries *s = qobject_cast<DeclarativeHorizontalPercentBarSeries *>(child); | |||
|
317 | connect(s, SIGNAL(axisXChanged(QAbstractAxis *)), this, SLOT(handleAxisXSet(QAbstractAxis *))); | |||
|
318 | connect(s, SIGNAL(axisYChanged(QAbstractAxis *)), this, SLOT(handleAxisYSet(QAbstractAxis *))); | |||
|
319 | setAxisX(s->axisX(), s); | |||
|
320 | setAxisY(s->axisY(), s); | |||
|
321 | } | |||
258 | }else if(qobject_cast<QAbstractAxis *>(child)){ |
|
322 | } else if(qobject_cast<QAbstractAxis *>(child)) { | |
259 |
|
323 | // Do nothing, axes are set for the chart in the context of series | ||
260 | } |
|
324 | } | |
261 | } |
|
325 | } | |
|
326 | ||||
|
327 | // Create the missing axes for the series that cannot be painted without axes | |||
|
328 | foreach(QAbstractSeries *series, m_chart->series()) | |||
|
329 | createDefaultAxes(series); | |||
|
330 | ||||
262 | QDeclarativeItem::componentComplete(); |
|
331 | QDeclarativeItem::componentComplete(); | |
263 | } |
|
332 | } | |
264 |
|
333 | |||
|
334 | void DeclarativeChart::handleAxisXSet(QAbstractAxis* axis) | |||
|
335 | { | |||
|
336 | // qDebug() << "DeclarativeChart::handleAxisXSet" << sender() << axis; | |||
|
337 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { | |||
|
338 | m_chart->setAxisX(axis, qobject_cast<DeclarativeLineSeries *>(sender())); | |||
|
339 | } | |||
|
340 | } | |||
|
341 | ||||
|
342 | void DeclarativeChart::handleAxisYSet(QAbstractAxis* axis) | |||
|
343 | { | |||
|
344 | // qDebug() << "DeclarativeChart::handleAxisYSet" << sender() << axis; | |||
|
345 | if (axis && qobject_cast<DeclarativeLineSeries *>(sender())) { | |||
|
346 | m_chart->setAxisY(axis, qobject_cast<DeclarativeLineSeries *>(sender())); | |||
|
347 | } | |||
|
348 | } | |||
|
349 | ||||
265 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
350 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | |
266 | { |
|
351 | { | |
267 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
352 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); | |
@@ -462,6 +547,7 QAbstractSeries *DeclarativeChart::series(QString seriesName) | |||||
462 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
547 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) | |
463 | { |
|
548 | { | |
464 | QAbstractSeries *series = 0; |
|
549 | QAbstractSeries *series = 0; | |
|
550 | ||||
465 | switch (type) { |
|
551 | switch (type) { | |
466 | case DeclarativeChart::SeriesTypeLine: |
|
552 | case DeclarativeChart::SeriesTypeLine: | |
467 | series = new DeclarativeLineSeries(); |
|
553 | series = new DeclarativeLineSeries(); | |
@@ -499,24 +585,90 QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType typ | |||||
499 | default: |
|
585 | default: | |
500 | qWarning() << "Illegal series type"; |
|
586 | qWarning() << "Illegal series type"; | |
501 | } |
|
587 | } | |
|
588 | ||||
|
589 | if (series) { | |||
502 | series->setName(name); |
|
590 | series->setName(name); | |
503 | m_chart->addSeries(series); |
|
591 | m_chart->addSeries(series); | |
|
592 | createDefaultAxes(series); | |||
|
593 | } | |||
|
594 | ||||
504 | return series; |
|
595 | return series; | |
505 | } |
|
596 | } | |
506 |
|
597 | |||
507 |
void DeclarativeChart::setAxisX(QAbstractAxis* |
|
598 | void DeclarativeChart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) | |
508 | { |
|
599 | { | |
|
600 | if (axis) | |||
509 | m_chart->setAxisX(axis,series); |
|
601 | m_chart->setAxisX(axis, series); | |
510 | } |
|
602 | } | |
511 |
|
603 | |||
512 |
void DeclarativeChart::setAxisY(QAbstractAxis* |
|
604 | void DeclarativeChart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) | |
513 | { |
|
605 | { | |
|
606 | if (axis) | |||
514 | m_chart->setAxisY(axis,series); |
|
607 | m_chart->setAxisY(axis, series); | |
515 | } |
|
608 | } | |
516 |
|
609 | |||
517 | void DeclarativeChart::createDefaultAxes() |
|
610 | void DeclarativeChart::createDefaultAxes() | |
518 | { |
|
611 | { | |
519 | m_chart->createDefaultAxes(); |
|
612 | qWarning() << "ChartView.createDefaultAxes() is deprecated. Axes are created automatically."; | |
|
613 | } | |||
|
614 | ||||
|
615 | void DeclarativeChart::createDefaultAxes(QAbstractSeries* series) | |||
|
616 | { | |||
|
617 | foreach (QAbstractSeries *s, m_chart->series()) { | |||
|
618 | // If there is already an x axis of the correct type, re-use it | |||
|
619 | if (!m_chart->axisX(series) && s != series && m_chart->axisX(s) | |||
|
620 | && m_chart->axisX(s)->type() == series->d_ptr->defaultAxisType(Qt::Horizontal)) | |||
|
621 | m_chart->setAxisX(m_chart->axisX(s), series); | |||
|
622 | ||||
|
623 | // If there is already a y axis of the correct type, re-use it | |||
|
624 | if (!m_chart->axisY(series) && s != series && m_chart->axisY(s) | |||
|
625 | && m_chart->axisY(s)->type() == series->d_ptr->defaultAxisType(Qt::Vertical)) | |||
|
626 | m_chart->setAxisY(m_chart->axisY(s), series); | |||
|
627 | } | |||
|
628 | ||||
|
629 | // If no x axis of correct type was found, create a new x axis based of default axis type | |||
|
630 | if (!m_chart->axisX(series)) { | |||
|
631 | switch (series->d_ptr->defaultAxisType(Qt::Horizontal)) { | |||
|
632 | case QAbstractAxis::AxisTypeValues: | |||
|
633 | m_chart->setAxisX(new QValueAxis(this), series); | |||
|
634 | break; | |||
|
635 | case QAbstractAxis::AxisTypeCategories: | |||
|
636 | m_chart->setAxisX(new QBarCategoryAxis(this), series); | |||
|
637 | break; | |||
|
638 | case QAbstractAxis::AxisTypeIntervals: | |||
|
639 | m_chart->setAxisX(new QIntervalsAxis(this), series); | |||
|
640 | break; | |||
|
641 | case QAbstractAxis::AxisTypeDateTime: | |||
|
642 | m_chart->setAxisX(new QDateTimeAxis(this), series); | |||
|
643 | break; | |||
|
644 | default: | |||
|
645 | // Do nothing, assume AxisTypeNoAxis | |||
|
646 | break; | |||
|
647 | } | |||
|
648 | } | |||
|
649 | ||||
|
650 | // If no y axis of correct type was found, create a new y axis based of default axis type | |||
|
651 | if (!m_chart->axisY(series)) { | |||
|
652 | switch (series->d_ptr->defaultAxisType(Qt::Vertical)) { | |||
|
653 | case QAbstractAxis::AxisTypeValues: | |||
|
654 | m_chart->setAxisY(new QValueAxis(this), series); | |||
|
655 | break; | |||
|
656 | case QAbstractAxis::AxisTypeCategories: | |||
|
657 | m_chart->setAxisY(new QBarCategoryAxis(this), series); | |||
|
658 | break; | |||
|
659 | case QAbstractAxis::AxisTypeIntervals: | |||
|
660 | m_chart->setAxisY(new QIntervalsAxis(this), series); | |||
|
661 | break; | |||
|
662 | case QAbstractAxis::AxisTypeDateTime: | |||
|
663 | m_chart->setAxisY(new QDateTimeAxis(this), series); | |||
|
664 | break; | |||
|
665 | default: | |||
|
666 | // Do nothing, assume AxisTypeNoAxis | |||
|
667 | break; | |||
|
668 | } | |||
|
669 | } | |||
|
670 | ||||
|
671 | //qDebug() << "axis for series" << series << "x:" << m_chart->axisX(series) << "y:" << m_chart->axisY(series); | |||
520 | } |
|
672 | } | |
521 |
|
673 | |||
522 | #include "moc_declarativechart.cpp" |
|
674 | #include "moc_declarativechart.cpp" |
@@ -27,7 +27,6 | |||||
27 |
|
27 | |||
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
29 |
|
29 | |||
30 | // TODO: Derive from QChart for easier definition of properties? |
|
|||
31 | class DeclarativeChart : public QDeclarativeItem |
|
30 | class DeclarativeChart : public QDeclarativeItem | |
32 | // TODO: for QTQUICK2: extend QQuickPainterItem instead |
|
31 | // TODO: for QTQUICK2: extend QQuickPainterItem instead | |
33 | //class DeclarativeChart : public QQuickPaintedItem, public Chart |
|
32 | //class DeclarativeChart : public QQuickPaintedItem, public Chart | |
@@ -49,6 +48,7 class DeclarativeChart : public QDeclarativeItem | |||||
49 | Q_ENUMS(Animation) |
|
48 | Q_ENUMS(Animation) | |
50 | Q_ENUMS(Theme) |
|
49 | Q_ENUMS(Theme) | |
51 | Q_ENUMS(SeriesType) |
|
50 | Q_ENUMS(SeriesType) | |
|
51 | // Q_ENUMS(AxisType) | |||
52 |
|
52 | |||
53 | public: |
|
53 | public: | |
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api |
|
54 | // duplicating enums from QChart to make the QML api namings 1-to-1 with the C++ api | |
@@ -114,8 +114,7 public: | |||||
114 | qreal bottomMargin(); |
|
114 | qreal bottomMargin(); | |
115 | qreal leftMargin(); |
|
115 | qreal leftMargin(); | |
116 | qreal rightMargin(); |
|
116 | qreal rightMargin(); | |
117 |
|
117 | void createDefaultAxes(QAbstractSeries* series); | ||
118 |
|
||||
119 |
|
118 | |||
120 | public: |
|
119 | public: | |
121 | Q_INVOKABLE QAbstractSeries *series(int index); |
|
120 | Q_INVOKABLE QAbstractSeries *series(int index); | |
@@ -145,6 +144,8 Q_SIGNALS: | |||||
145 |
|
144 | |||
146 | public Q_SLOTS: |
|
145 | public Q_SLOTS: | |
147 | void handleMarginsChanged(QRectF newMargins); |
|
146 | void handleMarginsChanged(QRectF newMargins); | |
|
147 | void handleAxisXSet(QAbstractAxis *axis); | |||
|
148 | void handleAxisYSet(QAbstractAxis *axis); | |||
148 |
|
149 | |||
149 | private: |
|
150 | private: | |
150 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
|
151 | // Extending QChart with DeclarativeChart is not possible because QObject does not support |
@@ -23,17 +23,14 | |||||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : |
|
25 | DeclarativeLineSeries::DeclarativeLineSeries(QObject *parent) : | |
26 | QLineSeries(parent) |
|
26 | QLineSeries(parent), | |
|
27 | m_axisX(0), | |||
|
28 | m_axisY(0) | |||
27 | { |
|
29 | { | |
28 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
30 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
29 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
30 | } |
|
32 | } | |
31 |
|
33 | |||
32 | QXYSeries *DeclarativeLineSeries::xySeries() |
|
|||
33 | { |
|
|||
34 | return this; |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | void DeclarativeLineSeries::handleCountChanged(int index) |
|
34 | void DeclarativeLineSeries::handleCountChanged(int index) | |
38 | { |
|
35 | { | |
39 | Q_UNUSED(index) |
|
36 | Q_UNUSED(index) |
@@ -33,12 +33,18 class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries, pu | |||||
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
36 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
37 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
38 |
|
40 | |||
39 | public: |
|
41 | public: | |
40 | explicit DeclarativeLineSeries(QObject *parent = 0); |
|
42 | explicit DeclarativeLineSeries(QObject *parent = 0); | |
41 | QXYSeries *xySeries(); |
|
43 | QXYSeries *xySeries() { return this; } | |
|
44 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
45 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
46 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
47 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
42 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
48 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
43 |
|
49 | |||
44 | public: // from QDeclarativeParserStatus |
|
50 | public: // from QDeclarativeParserStatus | |
@@ -55,10 +61,16 public: | |||||
55 |
|
61 | |||
56 | Q_SIGNALS: |
|
62 | Q_SIGNALS: | |
57 | void countChanged(int count); |
|
63 | void countChanged(int count); | |
|
64 | void axisXChanged(QAbstractAxis *axis); | |||
|
65 | void axisYChanged(QAbstractAxis *axis); | |||
58 |
|
66 | |||
59 | public Q_SLOTS: |
|
67 | public Q_SLOTS: | |
60 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
68 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
61 | void handleCountChanged(int index); |
|
69 | void handleCountChanged(int index); | |
|
70 | ||||
|
71 | private: | |||
|
72 | QAbstractAxis *m_axisX; | |||
|
73 | QAbstractAxis *m_axisY; | |||
62 | }; |
|
74 | }; | |
63 |
|
75 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -23,17 +23,14 | |||||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : |
|
25 | DeclarativeScatterSeries::DeclarativeScatterSeries(QObject *parent) : | |
26 | QScatterSeries(parent) |
|
26 | QScatterSeries(parent), | |
|
27 | m_axisX(0), | |||
|
28 | m_axisY(0) | |||
27 | { |
|
29 | { | |
28 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
30 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
29 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
30 | } |
|
32 | } | |
31 |
|
33 | |||
32 | QXYSeries *DeclarativeScatterSeries::xySeries() |
|
|||
33 | { |
|
|||
34 | return this; |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | void DeclarativeScatterSeries::handleCountChanged(int index) |
|
34 | void DeclarativeScatterSeries::handleCountChanged(int index) | |
38 | { |
|
35 | { | |
39 | Q_UNUSED(index) |
|
36 | Q_UNUSED(index) |
@@ -33,12 +33,18 class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeri | |||||
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
36 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
37 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
38 |
|
40 | |||
39 | public: |
|
41 | public: | |
40 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
|
42 | explicit DeclarativeScatterSeries(QObject *parent = 0); | |
41 | QXYSeries *xySeries(); |
|
43 | QXYSeries *xySeries() { return this; } | |
|
44 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
45 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
46 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
47 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
42 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
48 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
43 |
|
49 | |||
44 | public: // from QDeclarativeParserStatus |
|
50 | public: // from QDeclarativeParserStatus | |
@@ -55,10 +61,16 public: | |||||
55 |
|
61 | |||
56 | Q_SIGNALS: |
|
62 | Q_SIGNALS: | |
57 | void countChanged(int count); |
|
63 | void countChanged(int count); | |
|
64 | void axisXChanged(QAbstractAxis *axis); | |||
|
65 | void axisYChanged(QAbstractAxis *axis); | |||
58 |
|
66 | |||
59 | public Q_SLOTS: |
|
67 | public Q_SLOTS: | |
60 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
68 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
61 | void handleCountChanged(int index); |
|
69 | void handleCountChanged(int index); | |
|
70 | ||||
|
71 | private: | |||
|
72 | QAbstractAxis *m_axisX; | |||
|
73 | QAbstractAxis *m_axisY; | |||
62 | }; |
|
74 | }; | |
63 |
|
75 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -23,17 +23,14 | |||||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
24 | |||
25 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : |
|
25 | DeclarativeSplineSeries::DeclarativeSplineSeries(QObject *parent) : | |
26 | QSplineSeries(parent) |
|
26 | QSplineSeries(parent), | |
|
27 | m_axisX(0), | |||
|
28 | m_axisY(0) | |||
27 | { |
|
29 | { | |
28 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); |
|
30 | connect(this, SIGNAL(pointAdded(int)), this, SLOT(handleCountChanged(int))); | |
29 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); |
|
31 | connect(this, SIGNAL(pointRemoved(int)), this, SLOT(handleCountChanged(int))); | |
30 | } |
|
32 | } | |
31 |
|
33 | |||
32 | QXYSeries *DeclarativeSplineSeries::xySeries() |
|
|||
33 | { |
|
|||
34 | return this; |
|
|||
35 | } |
|
|||
36 |
|
||||
37 | void DeclarativeSplineSeries::handleCountChanged(int index) |
|
34 | void DeclarativeSplineSeries::handleCountChanged(int index) | |
38 | { |
|
35 | { | |
39 | Q_UNUSED(index) |
|
36 | Q_UNUSED(index) |
@@ -33,12 +33,18 class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries | |||||
33 | Q_OBJECT |
|
33 | Q_OBJECT | |
34 | Q_INTERFACES(QDeclarativeParserStatus) |
|
34 | Q_INTERFACES(QDeclarativeParserStatus) | |
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
|
35 | Q_PROPERTY(int count READ count NOTIFY countChanged) | |
|
36 | Q_PROPERTY(QAbstractAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) | |||
|
37 | Q_PROPERTY(QAbstractAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) | |||
36 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) |
|
38 | Q_PROPERTY(QDeclarativeListProperty<QObject> declarativeChildren READ declarativeChildren) | |
37 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") |
|
39 | Q_CLASSINFO("DefaultProperty", "declarativeChildren") | |
38 |
|
40 | |||
39 | public: |
|
41 | public: | |
40 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
|
42 | explicit DeclarativeSplineSeries(QObject *parent = 0); | |
41 | QXYSeries *xySeries(); |
|
43 | QXYSeries *xySeries() { return this; } | |
|
44 | QAbstractAxis *axisX() { return m_axisX; } | |||
|
45 | void setAxisX(QAbstractAxis *axis) { m_axisX = axis; emit axisXChanged(axis); } | |||
|
46 | QAbstractAxis *axisY() { return m_axisY; } | |||
|
47 | void setAxisY(QAbstractAxis *axis) { m_axisY = axis; emit axisYChanged(axis); } | |||
42 | QDeclarativeListProperty<QObject> declarativeChildren(); |
|
48 | QDeclarativeListProperty<QObject> declarativeChildren(); | |
43 |
|
49 | |||
44 | public: // from QDeclarativeParserStatus |
|
50 | public: // from QDeclarativeParserStatus | |
@@ -55,10 +61,16 public: | |||||
55 |
|
61 | |||
56 | Q_SIGNALS: |
|
62 | Q_SIGNALS: | |
57 | void countChanged(int count); |
|
63 | void countChanged(int count); | |
|
64 | void axisXChanged(QAbstractAxis *axis); | |||
|
65 | void axisYChanged(QAbstractAxis *axis); | |||
58 |
|
66 | |||
59 | public Q_SLOTS: |
|
67 | public Q_SLOTS: | |
60 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); |
|
68 | static void appendDeclarativeChildren(QDeclarativeListProperty<QObject> *list, QObject *element); | |
61 | void handleCountChanged(int index); |
|
69 | void handleCountChanged(int index); | |
|
70 | ||||
|
71 | public: | |||
|
72 | QAbstractAxis *m_axisX; | |||
|
73 | QAbstractAxis *m_axisY; | |||
62 | }; |
|
74 | }; | |
63 |
|
75 | |||
64 | QTCOMMERCIALCHART_END_NAMESPACE |
|
76 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -91,7 +91,7 public: | |||||
91 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", |
|
91 | qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries", | |
92 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); |
|
92 | QLatin1String("Trying to create uncreatable: AbstractBarSeries.")); | |
93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", |
|
93 | qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis", | |
94 | QLatin1String("Trying to create uncreatable: AbstractAxis.")); |
|
94 | QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead.")); | |
95 | } |
|
95 | } | |
96 | }; |
|
96 | }; | |
97 |
|
97 |
@@ -116,12 +116,13 void ChartDataSet::removeSeriesIndex(QAbstractSeries* series) | |||||
116 |
|
116 | |||
117 | void ChartDataSet::createDefaultAxes() |
|
117 | void ChartDataSet::createDefaultAxes() | |
118 | { |
|
118 | { | |
119 |
|
119 | if (m_seriesDomainMap.isEmpty()) | ||
120 | if(m_seriesDomainMap.isEmpty()) return; |
|
120 | return; | |
121 |
|
121 | |||
122 | QAbstractAxis::AxisTypes typeX(0); |
|
122 | QAbstractAxis::AxisTypes typeX(0); | |
123 | QAbstractAxis::AxisTypes typeY(0); |
|
123 | QAbstractAxis::AxisTypes typeY(0); | |
124 |
|
124 | |||
|
125 | // Remove possibly existing axes | |||
125 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
126 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
126 | while (i.hasNext()) { |
|
127 | while (i.hasNext()) { | |
127 | i.next(); |
|
128 | i.next(); | |
@@ -130,8 +131,10 void ChartDataSet::createDefaultAxes() | |||||
130 |
|
131 | |||
131 | i.toFront(); |
|
132 | i.toFront(); | |
132 |
|
133 | |||
|
134 | // Select the required axis x and axis y types based on the types of the current series | |||
133 | while (i.hasNext()) { |
|
135 | while (i.hasNext()) { | |
134 | i.next(); |
|
136 | i.next(); | |
|
137 | ||||
135 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); |
|
138 | QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); | |
136 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); |
|
139 | QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); | |
137 | if(axisX) typeX&=axisX->type(); |
|
140 | if(axisX) typeX&=axisX->type(); | |
@@ -140,6 +143,7 void ChartDataSet::createDefaultAxes() | |||||
140 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); |
|
143 | else typeY|=i.key()->d_ptr->defaultAxisType(Qt::Vertical); | |
141 | } |
|
144 | } | |
142 |
|
145 | |||
|
146 | // Create the axes of the types selected | |||
143 | createAxes(typeX,Qt::Horizontal); |
|
147 | createAxes(typeX, Qt::Horizontal); | |
144 | createAxes(typeY,Qt::Vertical); |
|
148 | createAxes(typeY, Qt::Vertical); | |
145 | } |
|
149 | } | |
@@ -148,18 +152,17 void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orie | |||||
148 | { |
|
152 | { | |
149 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
153 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
150 |
|
154 | |||
151 | if(type.testFlag(QAbstractAxis::AxisTypeValues) && type.testFlag(QAbstractAxis::AxisTypeCategories)) |
|
155 | // TODO: Add a descriptive comment of what happens here | |
152 | { |
|
156 | if (type.testFlag(QAbstractAxis::AxisTypeValues) && type.testFlag(QAbstractAxis::AxisTypeCategories)) { | |
153 | while (i.hasNext()) { |
|
157 | while (i.hasNext()) { | |
154 | i.next(); |
|
158 | i.next(); | |
155 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation),orientation); |
|
159 | QAbstractAxis* axis = createAxis(i.key()->d_ptr->defaultAxisType(orientation), orientation); | |
156 |
if( |
|
160 | if (axis) { | |
157 | initializeAxis(axis,i.key()); |
|
161 | initializeAxis(axis, i.key()); | |
158 | emit axisAdded(axis,i.value()); |
|
162 | emit axisAdded(axis, i.value()); | |
159 | } |
|
163 | } | |
160 |
|
||||
161 | } |
|
164 | } | |
162 | else if(!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { |
|
165 | } else if (!type.testFlag(QAbstractAxis::AxisTypeNoAxis)) { | |
163 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)),orientation); |
|
166 | QAbstractAxis* axis = createAxis(QAbstractAxis::AxisType(int(type)), orientation); | |
164 | i.toFront(); |
|
167 | i.toFront(); | |
165 | while (i.hasNext()) { |
|
168 | while (i.hasNext()) { | |
@@ -170,7 +173,6 void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type,Qt::Orientation orie | |||||
170 | } |
|
173 | } | |
171 | } |
|
174 | } | |
172 |
|
175 | |||
173 |
|
||||
174 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type,Qt::Orientation orientation) |
|
176 | QAbstractAxis* ChartDataSet::createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation) | |
175 | { |
|
177 | { | |
176 | QAbstractAxis* axis =0; |
|
178 | QAbstractAxis* axis = 0; | |
@@ -433,6 +435,11 void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Ori | |||||
433 | seriesAxisMap= &m_seriesAxisXMap; |
|
435 | seriesAxisMap= &m_seriesAxisXMap; | |
434 | } |
|
436 | } | |
435 |
|
437 | |||
|
438 | if (seriesAxisMap->value(series) == axis) { | |||
|
439 | qWarning() << "The axis already set for the series"; | |||
|
440 | return; | |||
|
441 | } | |||
|
442 | ||||
436 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); |
|
443 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); | |
437 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); |
|
444 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); | |
438 | if(oldAxis) { |
|
445 | if(oldAxis) { |
@@ -79,6 +79,7 protected: | |||||
79 | friend class ChartDataSet; |
|
79 | friend class ChartDataSet; | |
80 | friend class ChartPresenter; |
|
80 | friend class ChartPresenter; | |
81 | friend class QLegendPrivate; |
|
81 | friend class QLegendPrivate; | |
|
82 | friend class DeclarativeChart; | |||
82 | }; |
|
83 | }; | |
83 |
|
84 | |||
84 | QTCOMMERCIALCHART_END_NAMESPACE |
|
85 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -50,7 +50,6 | |||||
50 |
|
50 | |||
51 | The following QML shows how to create a chart with two simple scatter series: |
|
51 | The following QML shows how to create a chart with two simple scatter series: | |
52 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 |
|
52 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 1 | |
53 | \snippet ../demos/qmlchart/qml/qmlchart/View5.qml 2 |
|
|||
54 |
|
53 | |||
55 | \beginfloatleft |
|
54 | \beginfloatleft | |
56 | \image demos_qmlchart5.png |
|
55 | \image demos_qmlchart5.png |
@@ -68,10 +68,6 ChartView { | |||||
68 | onColorChanged: console.log(name + ".onColorChanged: " + color); |
|
68 | onColorChanged: console.log(name + ".onColorChanged: " + color); | |
69 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); |
|
69 | onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); | |
70 | // onCountChanged: console.log(name + ".onCountChanged: " + count); |
|
70 | // onCountChanged: console.log(name + ".onCountChanged: " + count); | |
71 |
|
||||
72 | Component.onCompleted: { |
|
|||
73 | createDefaultAxes(); |
|
|||
74 | } |
|
|||
75 | } |
|
71 | } | |
76 |
|
72 | |||
77 | AreaSeries { |
|
73 | AreaSeries { |
@@ -30,14 +30,11 ChartView { | |||||
30 |
|
30 | |||
31 | property variant series: mySeries |
|
31 | property variant series: mySeries | |
32 |
|
32 | |||
33 | BarCategoriesAxis { |
|
|||
34 | id:myAxis; |
|
|||
35 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } |
|
|||
36 |
|
33 | |||
37 | BarSeries { |
|
34 | BarSeries { | |
38 | id: mySeries |
|
35 | id: mySeries | |
39 | name: "bar" |
|
36 | name: "bar" | |
40 |
|
37 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | ||
41 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
42 | onClicked: console.log("barset.onClicked: " + index); |
|
39 | onClicked: console.log("barset.onClicked: " + index); | |
43 | onHovered: console.log("barset.onHovered: " + status); |
|
40 | onHovered: console.log("barset.onHovered: " + status); | |
@@ -64,10 +61,4 ChartView { | |||||
64 | onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
61 | onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
65 | onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); |
|
62 | onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); | |
66 | } |
|
63 | } | |
67 |
|
||||
68 | Component.onCompleted: { |
|
|||
69 | createDefaultAxes(); |
|
|||
70 | setAxisX(myAxis,mySeries); |
|
|||
71 | } |
|
|||
72 |
|
||||
73 | } |
|
64 | } |
@@ -107,8 +107,4 ChartView { | |||||
107 | NumberAnimation { duration: 800 } |
|
107 | NumberAnimation { duration: 800 } | |
108 | } |
|
108 | } | |
109 | } |
|
109 | } | |
110 |
|
||||
111 | Component.onCompleted: { |
|
|||
112 | createDefaultAxes(); |
|
|||
113 | } |
|
|||
114 | } |
|
110 | } |
@@ -59,8 +59,4 ChartView { | |||||
59 | XYPoint { x: 4.1; y: 2.3 } |
|
59 | XYPoint { x: 4.1; y: 2.3 } | |
60 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
60 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
61 | } |
|
61 | } | |
62 |
|
||||
63 | Component.onCompleted: { |
|
|||
64 | createDefaultAxes(); |
|
|||
65 | } |
|
|||
66 | } |
|
62 | } |
@@ -30,14 +30,11 ChartView { | |||||
30 |
|
30 | |||
31 | property variant series: mySeries |
|
31 | property variant series: mySeries | |
32 |
|
32 | |||
33 | BarCategoriesAxis { |
|
|||
34 | id: myAxis |
|
|||
35 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | PercentBarSeries { |
|
33 | PercentBarSeries { | |
39 | id: mySeries |
|
34 | id: mySeries | |
40 | name: "bar" |
|
35 | name: "bar" | |
|
36 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |||
|
37 | ||||
41 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
38 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
42 | onClicked: console.log("barset.onClicked: " + index); |
|
39 | onClicked: console.log("barset.onClicked: " + index); | |
43 | onHovered: console.log("barset.onHovered: " + status); |
|
40 | onHovered: console.log("barset.onHovered: " + status); | |
@@ -64,9 +61,4 ChartView { | |||||
64 | onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
61 | onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
65 | onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); |
|
62 | onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); | |
66 | } |
|
63 | } | |
67 |
|
||||
68 | Component.onCompleted: { |
|
|||
69 | createDefaultAxes(); |
|
|||
70 | setAxisX(myAxis,mySeries); |
|
|||
71 | } |
|
|||
72 | } |
|
64 | } |
@@ -58,8 +58,4 ChartView { | |||||
58 | XYPoint { x: 2.67; y: 2.65 } |
|
58 | XYPoint { x: 2.67; y: 2.65 } | |
59 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
59 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
60 | } |
|
60 | } | |
61 |
|
||||
62 | Component.onCompleted: { |
|
|||
63 | createDefaultAxes(); |
|
|||
64 | } |
|
|||
65 | } |
|
61 | } |
@@ -58,8 +58,4 ChartView { | |||||
58 | XYPoint { x: 4.1; y: 2.3 } |
|
58 | XYPoint { x: 4.1; y: 2.3 } | |
59 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); |
|
59 | onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); | |
60 | } |
|
60 | } | |
61 |
|
||||
62 | Component.onCompleted: { |
|
|||
63 | createDefaultAxes(); |
|
|||
64 | } |
|
|||
65 | } |
|
61 | } |
@@ -30,14 +30,10 ChartView { | |||||
30 |
|
30 | |||
31 | property variant series: mySeries |
|
31 | property variant series: mySeries | |
32 |
|
32 | |||
33 | BarCategoriesAxis { |
|
|||
34 | id: myAxis |
|
|||
35 | categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] |
|
|||
36 | } |
|
|||
37 |
|
||||
38 | StackedBarSeries { |
|
33 | StackedBarSeries { | |
39 | id: mySeries |
|
34 | id: mySeries | |
40 | name: "bar" |
|
35 | name: "bar" | |
|
36 | axisX: BarCategoriesAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } | |||
41 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] |
|
37 | BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] | |
42 | onClicked: console.log("barset.onClicked: " + index); |
|
38 | onClicked: console.log("barset.onClicked: " + index); | |
43 | onHovered: console.log("barset.onHovered: " + status); |
|
39 | onHovered: console.log("barset.onHovered: " + status); | |
@@ -64,9 +60,4 ChartView { | |||||
64 | onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); |
|
60 | onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); | |
65 | onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); |
|
61 | onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); | |
66 | } |
|
62 | } | |
67 |
|
||||
68 | Component.onCompleted: { |
|
|||
69 | createDefaultAxes(); |
|
|||
70 | setAxisX(myAxis,mySeries); |
|
|||
71 | } |
|
|||
72 | } |
|
63 | } |
General Comments 0
You need to be logged in to leave comments.
Login now