##// END OF EJS Templates
Renamed QML ValuesAxis to ValueAxis
Tero Ahola -
r1814:c053fa384024
parent child
Show More
@@ -1,180 +1,180
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23 import QmlCustomModel 1.0
23 import QmlCustomModel 1.0
24
24
25 Rectangle {
25 Rectangle {
26 anchors.fill: parent
26 anchors.fill: parent
27
27
28 //![1]
28 //![1]
29 ChartView {
29 ChartView {
30 id: chartView
30 id: chartView
31 title: "Top-5 car brand shares in Finland"
31 title: "Top-5 car brand shares in Finland"
32 anchors.fill: parent
32 anchors.fill: parent
33 animationOptions: ChartView.SeriesAnimations
33 animationOptions: ChartView.SeriesAnimations
34
34
35 BarCategoriesAxis {
35 BarCategoriesAxis {
36 id: categoriesAxis
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"
38 min: "2007"
39 max: "2014"
39 max: "2014"
40 }
40 }
41
41
42 ValuesAxis {
42 ValueAxis {
43 id: valuesAxis
43 id: valueAxis
44 min: 0
44 min: 0
45 max: 60
45 max: 60
46 }
46 }
47 // ...
47 // ...
48 //![1]
48 //![1]
49
49
50 //![2]
50 //![2]
51 CustomModel {
51 CustomModel {
52 id: customModel
52 id: customModel
53 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
53 verticalHeaders: ["Manufacturer", "Volkswagen", "Toyota", "Ford", "Skoda", "Volvo", "Others"]
54 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
54 CustomModelElement { values: [0, "Manufacturer", 0, 1, 2, 3, 4] }
55 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
55 CustomModelElement { values: [1, "Volkswagen", 10.3, 12.0, 12.8, 13.0, 13.8] }
56 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
56 CustomModelElement { values: [2, "Toyota", 13.8, 13.5, 16.2, 13.7, 10.7] }
57 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
57 CustomModelElement { values: [3, "Ford", 6.4, 7.1, 8.9, 8.2, 8.6] }
58 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
58 CustomModelElement { values: [4, "Skoda", 4.7, 5.8, 6.9, 8.3, 8.2] }
59 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
59 CustomModelElement { values: [5, "Volvo", 7.1, 6.7, 6.5, 6.3, 7.0] }
60 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
60 CustomModelElement { values: [6, "Others", 57.7, 54.9, 48.7, 50.5, 51.7] }
61 }
61 }
62 //![2]
62 //![2]
63
63
64 //![5]
64 //![5]
65 BarSeries {
65 BarSeries {
66 id: myBarSeries
66 id: myBarSeries
67 name: "Others"
67 name: "Others"
68 axisX: categoriesAxis
68 axisX: categoriesAxis
69 axisY: valuesAxis
69 axisY: valueAxis
70 barWidth: 0.9
70 barWidth: 0.9
71 visible: false
71 visible: false
72 HBarModelMapper {
72 HBarModelMapper {
73 model: customModel
73 model: customModel
74 firstBarSetRow: 6
74 firstBarSetRow: 6
75 lastBarSetRow: 6
75 lastBarSetRow: 6
76 firstColumn: 2
76 firstColumn: 2
77 }
77 }
78 }
78 }
79 //![5]
79 //![5]
80
80
81 //![4]
81 //![4]
82 LineSeries {
82 LineSeries {
83 id: lineSeries1
83 id: lineSeries1
84 name: "Volkswagen"
84 name: "Volkswagen"
85 axisX: categoriesAxis
85 axisX: categoriesAxis
86 axisY: valuesAxis
86 axisY: valueAxis
87 visible: false
87 visible: false
88 HXYModelMapper {
88 HXYModelMapper {
89 model: customModel
89 model: customModel
90 xRow: 0
90 xRow: 0
91 yRow: 1
91 yRow: 1
92 firstColumn: 2
92 firstColumn: 2
93 }
93 }
94 }
94 }
95 //![4]
95 //![4]
96
96
97 LineSeries {
97 LineSeries {
98 id: lineSeries2
98 id: lineSeries2
99 name: "Toyota"
99 name: "Toyota"
100 axisX: categoriesAxis
100 axisX: categoriesAxis
101 axisY: valuesAxis
101 axisY: valueAxis
102 visible: false
102 visible: false
103 HXYModelMapper {
103 HXYModelMapper {
104 model: customModel
104 model: customModel
105 xRow: 0
105 xRow: 0
106 yRow: 2
106 yRow: 2
107 firstColumn: 2
107 firstColumn: 2
108 }
108 }
109 }
109 }
110
110
111 LineSeries {
111 LineSeries {
112 id: lineSeries3
112 id: lineSeries3
113 name: "Ford"
113 name: "Ford"
114 axisX: categoriesAxis
114 axisX: categoriesAxis
115 axisY: valuesAxis
115 axisY: valueAxis
116 visible: false
116 visible: false
117 HXYModelMapper {
117 HXYModelMapper {
118 model: customModel
118 model: customModel
119 xRow: 0
119 xRow: 0
120 yRow: 3
120 yRow: 3
121 firstColumn: 2
121 firstColumn: 2
122 }
122 }
123 }
123 }
124
124
125 LineSeries {
125 LineSeries {
126 id: lineSeries4
126 id: lineSeries4
127 name: "Skoda"
127 name: "Skoda"
128 axisX: categoriesAxis
128 axisX: categoriesAxis
129 axisY: valuesAxis
129 axisY: valueAxis
130 visible: false
130 visible: false
131 HXYModelMapper {
131 HXYModelMapper {
132 model: customModel
132 model: customModel
133 xRow: 0
133 xRow: 0
134 yRow: 4
134 yRow: 4
135 firstColumn: 2
135 firstColumn: 2
136 }
136 }
137 }
137 }
138
138
139 LineSeries {
139 LineSeries {
140 id: lineSeries5
140 id: lineSeries5
141 name: "Volvo"
141 name: "Volvo"
142 axisX: categoriesAxis
142 axisX: categoriesAxis
143 axisY: valuesAxis
143 axisY: valueAxis
144 visible: false
144 visible: false
145 HXYModelMapper {
145 HXYModelMapper {
146 model: customModel
146 model: customModel
147 xRow: 0
147 xRow: 0
148 yRow: 5
148 yRow: 5
149 firstColumn: 2
149 firstColumn: 2
150 }
150 }
151 }
151 }
152
152
153 //![3]
153 //![3]
154 PieSeries {
154 PieSeries {
155 id: pieSeries
155 id: pieSeries
156 size: 0.4
156 size: 0.4
157 horizontalPosition: 0.85
157 horizontalPosition: 0.85
158 verticalPosition: 0.4
158 verticalPosition: 0.4
159 onClicked: {
159 onClicked: {
160 // Show the selection by exploding the slice
160 // Show the selection by exploding the slice
161 slice.exploded = !slice.exploded;
161 slice.exploded = !slice.exploded;
162
162
163 // Update the line series to show the yearly data for this slice
163 // Update the line series to show the yearly data for this slice
164 for (var i = 0; i < chartView.count; i++) {
164 for (var i = 0; i < chartView.count; i++) {
165 if (chartView.series(i).name == slice.label) {
165 if (chartView.series(i).name == slice.label) {
166 chartView.series(i).visible = slice.exploded;
166 chartView.series(i).visible = slice.exploded;
167 }
167 }
168 }
168 }
169 }
169 }
170
170
171 VPieModelMapper {
171 VPieModelMapper {
172 model: customModel
172 model: customModel
173 labelsColumn: 1
173 labelsColumn: 1
174 valuesColumn: 2
174 valuesColumn: 2
175 firstRow: 1
175 firstRow: 1
176 }
176 }
177 }
177 }
178 //![3]
178 //![3]
179 }
179 }
180 }
180 }
@@ -1,94 +1,92
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 animationOptions: ChartView.NoAnimation
26 animationOptions: ChartView.NoAnimation
27
27
28 ValuesAxis {
28 ValueAxis {
29 id: axisY
29 id: axisY
30 min: -1
30 min: -1
31 max: 3
31 max: 3
32 }
32 }
33
33
34 ValuesAxis {
34 ValueAxis {
35 id: axisX
35 id: axisX
36 min: 0
36 min: 0
37 max: 1000
37 max: 1000
38 }
38 }
39
39
40 LineSeries {
40 LineSeries {
41 id: lineSeries1
41 id: lineSeries1
42 name: "signal 1"
42 name: "signal 1"
43 axisX: axisX
43 axisX: axisX
44 axisY: axisY
44 axisY: axisY
45 }
45 }
46 LineSeries {
46 LineSeries {
47 id: lineSeries2
47 id: lineSeries2
48 name: "signal 2"
48 name: "signal 2"
49 axisX: axisX
49 axisX: axisX
50 axisY: axisY
50 axisY: axisY
51 }
51 }
52
52
53 Timer {
53 Timer {
54 id: refreshTimer
54 id: refreshTimer
55 interval: 1 / 60 * 1000 // 60 Hz
55 interval: 1 / 60 * 1000 // 60 Hz
56 running: true
56 running: true
57 repeat: true
57 repeat: true
58 onTriggered: {
58 onTriggered: {
59 dataSource.update(chartView.series(0));
59 dataSource.update(chartView.series(0));
60 dataSource.update(chartView.series(1));
60 dataSource.update(chartView.series(1));
61 }
61 }
62 }
62 }
63
63
64 function changeSeriesType(type) {
64 function changeSeriesType(type) {
65 chartView.series(1).destroy();
65 chartView.series(1).destroy();
66 chartView.series(0).destroy();
66 chartView.series(0).destroy();
67 var seriesCount = 2;
67 var seriesCount = 2;
68 for (var i = 0; i < seriesCount; i++) {
68 for (var i = 0; i < seriesCount; i++) {
69 var series;
69 var series;
70 if (type == "line") {
70 if (type == "line") {
71 series = scopeView.createSeries(ChartView.SeriesTypeLine, "signal " + (i + 1));
71 series = scopeView.createSeries(ChartView.SeriesTypeLine, "signal " + (i + 1));
72 } else if (type == "spline") {
72 } else if (type == "spline") {
73 series = chartView.createSeries(ChartView.SeriesTypeSpline, "signal " + (i + 1));
73 series = chartView.createSeries(ChartView.SeriesTypeSpline, "signal " + (i + 1));
74 } else {
74 } else {
75 series = chartView.createSeries(ChartView.SeriesTypeScatter, "signal " + (i + 1));
75 series = chartView.createSeries(ChartView.SeriesTypeScatter, "signal " + (i + 1));
76 series.markerSize = 3;
76 series.markerSize = 3;
77 series.borderColor = "transparent";
77 series.borderColor = "transparent";
78 }
78 }
79 // chartView.setAxisX(axisX, series);
80 // chartView.setAxisY(axisY, series);
81 }
79 }
82 }
80 }
83
81
84 function setAnimations(enabled) {
82 function setAnimations(enabled) {
85 if (enabled)
83 if (enabled)
86 scopeView.animationOptions = ChartView.SeriesAnimations;
84 scopeView.animationOptions = ChartView.SeriesAnimations;
87 else
85 else
88 scopeView.animationOptions = ChartView.NoAnimation;
86 scopeView.animationOptions = ChartView.NoAnimation;
89 }
87 }
90
88
91 function changeRefreshRate(rate) {
89 function changeRefreshRate(rate) {
92 refreshTimer.interval = 1 / Number(rate) * 1000;
90 refreshTimer.interval = 1 / Number(rate) * 1000;
93 }
91 }
94 }
92 }
@@ -1,182 +1,182
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.1
21 import QtQuick 1.1
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 Rectangle {
24 Rectangle {
25 width: 360
25 width: 360
26 height: 360
26 height: 360
27
27
28 //![1]
28 //![1]
29 ChartView {
29 ChartView {
30 id: chartView
30 id: chartView
31 title: "Weather forecast"
31 title: "Weather forecast"
32 //![1]
32 //![1]
33 anchors.top: parent.top
33 anchors.top: parent.top
34 anchors.bottom: weatherImageRow.top
34 anchors.bottom: weatherImageRow.top
35 anchors.left: parent.left
35 anchors.left: parent.left
36 anchors.right: parent.right
36 anchors.right: parent.right
37 legend.alignment: Qt.AlignTop
37 legend.alignment: Qt.AlignTop
38
38
39 //![2]
39 //![2]
40 BarCategoriesAxis {
40 BarCategoriesAxis {
41 id: barCategoriesAxis
41 id: barCategoriesAxis
42 }
42 }
43
43
44 BarSeries {
44 BarSeries {
45 id: myBarSeries
45 id: myBarSeries
46 axisX: barCategoriesAxis
46 axisX: barCategoriesAxis
47 axisY: valuesAxisY
47 axisY: valueAxisY
48 BarSet {
48 BarSet {
49 id: rainfallSet
49 id: rainfallSet
50 label: "Rainfall"
50 label: "Rainfall"
51 }
51 }
52 }
52 }
53
53
54 ValuesAxis {
54 ValueAxis {
55 id: valuesAxisX
55 id: valueAxisX
56 min: 0
56 min: 0
57 max: 5
57 max: 5
58 }
58 }
59
59
60 ValuesAxis{
60 ValueAxis{
61 id: valuesAxisY
61 id: valueAxisY
62 min: 0
62 min: 0
63 max: 10
63 max: 10
64 }
64 }
65
65
66 LineSeries {
66 LineSeries {
67 id: maxTempSeries
67 id: maxTempSeries
68 axisX: valuesAxisX
68 axisX: valueAxisX
69 axisY: valuesAxisY
69 axisY: valueAxisY
70 name: "Max. temperature"
70 name: "Max. temperature"
71 }
71 }
72
72
73 LineSeries {
73 LineSeries {
74 id: minTempSeries
74 id: minTempSeries
75 axisX: valuesAxisX
75 axisX: valueAxisX
76 axisY: valuesAxisY
76 axisY: valueAxisY
77 name: "Min. temperature"
77 name: "Min. temperature"
78 }
78 }
79 //![2]
79 //![2]
80 }
80 }
81
81
82 // A timer to refresh the forecast every 5 minutes
82 // A timer to refresh the forecast every 5 minutes
83 Timer {
83 Timer {
84 interval: 300000
84 interval: 300000
85 repeat: true
85 repeat: true
86 triggeredOnStart: true
86 triggeredOnStart: true
87 running: true
87 running: true
88 onTriggered: {
88 onTriggered: {
89 if (weatherAppKey != "") {
89 if (weatherAppKey != "") {
90 //![3]
90 //![3]
91 // Make HTTP GET request and parse the result
91 // Make HTTP GET request and parse the result
92 var xhr = new XMLHttpRequest;
92 var xhr = new XMLHttpRequest;
93 xhr.open("GET",
93 xhr.open("GET",
94 "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
94 "http://free.worldweatheronline.com/feed/weather.ashx?q=Jyv%c3%a4skyl%c3%a4,Finland&format=json&num_of_days=5&key="
95 + weatherAppKey);
95 + weatherAppKey);
96 xhr.onreadystatechange = function() {
96 xhr.onreadystatechange = function() {
97 if (xhr.readyState == XMLHttpRequest.DONE) {
97 if (xhr.readyState == XMLHttpRequest.DONE) {
98 var a = JSON.parse(xhr.responseText);
98 var a = JSON.parse(xhr.responseText);
99 parseWeatherData(a);
99 parseWeatherData(a);
100 }
100 }
101 }
101 }
102 xhr.send();
102 xhr.send();
103 //![3]
103 //![3]
104 } else {
104 } else {
105 // No app key for worldweatheronline.com given by the user -> use dummy static data
105 // No app key for worldweatheronline.com given by the user -> use dummy static data
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\" } ] }}";
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\" } ] }}";
107 var a = JSON.parse(responseText);
107 var a = JSON.parse(responseText);
108 parseWeatherData(a);
108 parseWeatherData(a);
109 }
109 }
110 }
110 }
111 }
111 }
112
112
113 Row {
113 Row {
114 id: weatherImageRow
114 id: weatherImageRow
115 anchors.bottom: poweredByText.top
115 anchors.bottom: poweredByText.top
116 anchors.bottomMargin: 10
116 anchors.bottomMargin: 10
117 anchors.left: parent.left
117 anchors.left: parent.left
118 anchors.leftMargin: 25
118 anchors.leftMargin: 25
119 anchors.right: parent.right
119 anchors.right: parent.right
120 anchors.rightMargin: 25
120 anchors.rightMargin: 25
121
121
122 ListModel {
122 ListModel {
123 id: weatherImageModel
123 id: weatherImageModel
124 }
124 }
125
125
126 Repeater {
126 Repeater {
127 id: repeater
127 id: repeater
128 model: weatherImageModel
128 model: weatherImageModel
129 delegate: Image {
129 delegate: Image {
130 source: imageSource
130 source: imageSource
131 width: weatherImageRow.width / weatherImageModel.count
131 width: weatherImageRow.width / weatherImageModel.count
132 height: width
132 height: width
133 fillMode: Image.PreserveAspectCrop
133 fillMode: Image.PreserveAspectCrop
134 }
134 }
135 }
135 }
136 }
136 }
137
137
138 Text {
138 Text {
139 id: poweredByText
139 id: poweredByText
140 anchors.bottom: parent.bottom
140 anchors.bottom: parent.bottom
141 anchors.bottomMargin: 10
141 anchors.bottomMargin: 10
142 anchors.left: parent.left
142 anchors.left: parent.left
143 anchors.leftMargin: 25
143 anchors.leftMargin: 25
144 text: "Powered by World Weather Online"
144 text: "Powered by World Weather Online"
145 }
145 }
146
146
147 function parseWeatherData(weatherData) {
147 function parseWeatherData(weatherData) {
148 // Clear previous values
148 // Clear previous values
149 maxTempSeries.clear();
149 maxTempSeries.clear();
150 minTempSeries.clear();
150 minTempSeries.clear();
151 weatherImageModel.clear();
151 weatherImageModel.clear();
152
152
153 //![4]
153 //![4]
154 // Loop through the parsed JSON
154 // Loop through the parsed JSON
155 for (var i in weatherData.data.weather) {
155 for (var i in weatherData.data.weather) {
156 var weatherObj = weatherData.data.weather[i];
156 var weatherObj = weatherData.data.weather[i];
157 //![4]
157 //![4]
158
158
159 //![5]
159 //![5]
160 // Store temperature values, rainfall and weather icon
160 // Store temperature values, rainfall and weather icon
161 maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
161 maxTempSeries.append(Number(i) + 0.5, weatherObj.tempMaxC);
162 minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
162 minTempSeries.append(Number(i) + 0.5, weatherObj.tempMinC);
163 rainfallSet.append(i, weatherObj.precipMM);
163 rainfallSet.append(i, weatherObj.precipMM);
164 weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
164 weatherImageModel.append({"imageSource":weatherObj.weatherIconUrl[0].value});
165 //![5]
165 //![5]
166
166
167 // Update scale of the chart
167 // Update scale of the chart
168 valuesAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
168 valueAxisY.max = Math.max(chartView.axisY().max,weatherObj.tempMaxC);
169 valuesAxisX.min = 0;
169 valueAxisX.min = 0;
170 valuesAxisX.max = Number(i) + 1;
170 valueAxisX.max = Number(i) + 1;
171
171
172 // Set the x-axis labels to the dates of the forecast
172 // Set the x-axis labels to the dates of the forecast
173 var xLabels = barCategoriesAxis.categories;
173 var xLabels = barCategoriesAxis.categories;
174 xLabels[Number(i)] = weatherObj.date.substring(5, 10);
174 xLabels[Number(i)] = weatherObj.date.substring(5, 10);
175 barCategoriesAxis.categories = xLabels;
175 barCategoriesAxis.categories = xLabels;
176 barCategoriesAxis.visible = true;
176 barCategoriesAxis.visible = true;
177 barCategoriesAxis.min = 0;
177 barCategoriesAxis.min = 0;
178 barCategoriesAxis.max = xLabels.length - 1;
178 barCategoriesAxis.max = xLabels.length - 1;
179 }
179 }
180 }
180 }
181
181
182 }
182 }
@@ -1,104 +1,104
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
21 #include <QtDeclarative/qdeclarativeextensionplugin.h>
22 #include <QtDeclarative/qdeclarative.h>
22 #include <QtDeclarative/qdeclarative.h>
23 #include "qchart.h"
23 #include "qchart.h"
24 #include "qabstractaxis.h"
24 #include "qabstractaxis.h"
25 #include "qvalueaxis.h"
25 #include "qvalueaxis.h"
26 #include "qbarcategoryaxis.h"
26 #include "qbarcategoryaxis.h"
27 #include "declarativechart.h"
27 #include "declarativechart.h"
28 #include "declarativexypoint.h"
28 #include "declarativexypoint.h"
29 #include "declarativelineseries.h"
29 #include "declarativelineseries.h"
30 #include "declarativesplineseries.h"
30 #include "declarativesplineseries.h"
31 #include "declarativeareaseries.h"
31 #include "declarativeareaseries.h"
32 #include "declarativescatterseries.h"
32 #include "declarativescatterseries.h"
33 #include "declarativebarseries.h"
33 #include "declarativebarseries.h"
34 #include "declarativepieseries.h"
34 #include "declarativepieseries.h"
35 #include "qvxymodelmapper.h"
35 #include "qvxymodelmapper.h"
36 #include "qhxymodelmapper.h"
36 #include "qhxymodelmapper.h"
37 #include "qhpiemodelmapper.h"
37 #include "qhpiemodelmapper.h"
38 #include "qvpiemodelmapper.h"
38 #include "qvpiemodelmapper.h"
39 #include "qhbarmodelmapper.h"
39 #include "qhbarmodelmapper.h"
40 #include "qvbarmodelmapper.h"
40 #include "qvbarmodelmapper.h"
41 #include <QAbstractItemModel>
41 #include <QAbstractItemModel>
42
42
43 QTCOMMERCIALCHART_BEGIN_NAMESPACE
43 QTCOMMERCIALCHART_BEGIN_NAMESPACE
44
44
45 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
45 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
46 {
46 {
47 Q_OBJECT
47 Q_OBJECT
48 public:
48 public:
49 virtual void registerTypes(const char *uri)
49 virtual void registerTypes(const char *uri)
50 {
50 {
51 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
51 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
52
52
53 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
53 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
54 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
54 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
55 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
55 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
56 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
56 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
57 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
57 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
58 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
58 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
59 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
59 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
60 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
60 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
61 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
61 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
62 qmlRegisterType<DeclarativeHorizontalBarSeries>(uri, 1, 0, "HorizontalBarSeries");
62 qmlRegisterType<DeclarativeHorizontalBarSeries>(uri, 1, 0, "HorizontalBarSeries");
63 qmlRegisterType<DeclarativeHorizontalStackedBarSeries>(uri, 1, 0, "HorizontalStackedBarSeries");
63 qmlRegisterType<DeclarativeHorizontalStackedBarSeries>(uri, 1, 0, "HorizontalStackedBarSeries");
64 qmlRegisterType<DeclarativeHorizontalPercentBarSeries>(uri, 1, 0, "HorizontalPercentBarSeries");
64 qmlRegisterType<DeclarativeHorizontalPercentBarSeries>(uri, 1, 0, "HorizontalPercentBarSeries");
65 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
65 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
66 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
66 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
67 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
67 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
68 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
68 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
69 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
69 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
70 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
70 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
71 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
71 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
72 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
72 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
73 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
73 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
74 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
74 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValueAxis");
75 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
75 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
76
76
77 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
77 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
78 QLatin1String("Trying to create uncreatable: Legend."));
78 QLatin1String("Trying to create uncreatable: Legend."));
79 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
79 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
80 QLatin1String("Trying to create uncreatable: XYSeries."));
80 QLatin1String("Trying to create uncreatable: XYSeries."));
81 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
81 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
82 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
82 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
83 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
83 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
84 QLatin1String("Trying to create uncreatable: XYModelMapper."));
84 QLatin1String("Trying to create uncreatable: XYModelMapper."));
85 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
85 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
86 QLatin1String("Trying to create uncreatable: PieModelMapper."));
86 QLatin1String("Trying to create uncreatable: PieModelMapper."));
87 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
87 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
88 QLatin1String("Trying to create uncreatable: BarModelMapper."));
88 QLatin1String("Trying to create uncreatable: BarModelMapper."));
89 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
89 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
90 QLatin1String("Trying to create uncreatable: AbstractSeries."));
90 QLatin1String("Trying to create uncreatable: AbstractSeries."));
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. Use specific types of axis instead."));
94 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
95 }
95 }
96 };
96 };
97
97
98 #include "plugin.moc"
98 #include "plugin.moc"
99
99
100 QTCOMMERCIALCHART_END_NAMESPACE
100 QTCOMMERCIALCHART_END_NAMESPACE
101
101
102 QTCOMMERCIALCHART_USE_NAMESPACE
102 QTCOMMERCIALCHART_USE_NAMESPACE
103
103
104 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
104 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
@@ -1,110 +1,110
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant series: chartView
28 property variant series: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XYPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XYPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onTopMarginChanged: {
45 onTopMarginChanged: {
46 console.log("chart.onTopMarginChanged: " + margin);
46 console.log("chart.onTopMarginChanged: " + margin);
47 marginVisualizer.opacity = 1.0;
47 marginVisualizer.opacity = 1.0;
48 }
48 }
49 onBottomMarginChanged: {
49 onBottomMarginChanged: {
50 console.log("chart.onBottomMarginChanged: " + margin);
50 console.log("chart.onBottomMarginChanged: " + margin);
51 marginVisualizer.opacity = 1.0;
51 marginVisualizer.opacity = 1.0;
52 }
52 }
53 onLeftMarginChanged: {
53 onLeftMarginChanged: {
54 console.log("chart.onLeftMarginChanged: " + margin);
54 console.log("chart.onLeftMarginChanged: " + margin);
55 marginVisualizer.opacity = 1.0;
55 marginVisualizer.opacity = 1.0;
56 }
56 }
57 onRightMarginChanged: {
57 onRightMarginChanged: {
58 console.log("chart.onRightMarginChanged: " + margin);
58 console.log("chart.onRightMarginChanged: " + margin);
59 marginVisualizer.opacity = 1.0;
59 marginVisualizer.opacity = 1.0;
60 }
60 }
61
61
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
67
67
68
68
69 ValuesAxis{
69 ValueAxis{
70 onColorChanged: console.log("axisX.onColorChanged: " + color);
70 onColorChanged: console.log("axisX.onColorChanged: " + color);
71 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
71 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
72 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
72 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
73 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
73 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
74 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
74 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
75 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
75 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
76 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
76 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
77 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
77 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
78 onMinChanged: console.log("axisX.onMinChanged: " + min);
78 onMinChanged: console.log("axisX.onMinChanged: " + min);
79 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
79 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
80 }
80 }
81
81
82 ValuesAxis{
82 ValueAxis{
83 onColorChanged: console.log("axisY.onColorChanged: " + color);
83 onColorChanged: console.log("axisY.onColorChanged: " + color);
84 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
84 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
85 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
85 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
86 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
86 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
87 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
87 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
88 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
88 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
89 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
89 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
90 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
90 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
91 onMinChanged: console.log("axisY.onMinChanged: " + min);
91 onMinChanged: console.log("axisY.onMinChanged: " + min);
92 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
92 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
93 }
93 }
94
94
95 Rectangle {
95 Rectangle {
96 id: marginVisualizer
96 id: marginVisualizer
97 color: "transparent"
97 color: "transparent"
98 border.color: "red"
98 border.color: "red"
99 anchors.fill: parent
99 anchors.fill: parent
100 anchors.topMargin: parent.topMargin
100 anchors.topMargin: parent.topMargin
101 anchors.bottomMargin: parent.bottomMargin
101 anchors.bottomMargin: parent.bottomMargin
102 anchors.leftMargin: parent.leftMargin
102 anchors.leftMargin: parent.leftMargin
103 anchors.rightMargin: parent.rightMargin
103 anchors.rightMargin: parent.rightMargin
104 opacity: 0.0
104 opacity: 0.0
105 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
105 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
106 Behavior on opacity {
106 Behavior on opacity {
107 NumberAnimation { duration: 800 }
107 NumberAnimation { duration: 800 }
108 }
108 }
109 }
109 }
110 }
110 }
@@ -1,64 +1,64
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 title: "user defined axes"
25 title: "user defined axes"
26
26
27 ValuesAxis {
27 ValueAxis {
28 id: axisX
28 id: axisX
29 min: 0
29 min: 0
30 max: 10
30 max: 10
31 }
31 }
32
32
33 ValuesAxis {
33 ValueAxis {
34 id: axisY
34 id: axisY
35 min: 0
35 min: 0
36 max: 6
36 max: 6
37 }
37 }
38
38
39 LineSeries {
39 LineSeries {
40 name: "line series"
40 name: "line series"
41 axisX: axisX
41 axisX: axisX
42 axisY: axisY
42 axisY: axisY
43 XYPoint { x: 0; y: 0 }
43 XYPoint { x: 0; y: 0 }
44 XYPoint { x: 1.1; y: 2.1 }
44 XYPoint { x: 1.1; y: 2.1 }
45 XYPoint { x: 1.9; y: 3.3 }
45 XYPoint { x: 1.9; y: 3.3 }
46 XYPoint { x: 2.1; y: 2.1 }
46 XYPoint { x: 2.1; y: 2.1 }
47 XYPoint { x: 2.9; y: 4.9 }
47 XYPoint { x: 2.9; y: 4.9 }
48 XYPoint { x: 3.4; y: 3.0 }
48 XYPoint { x: 3.4; y: 3.0 }
49 XYPoint { x: 4.1; y: 3.3 }
49 XYPoint { x: 4.1; y: 3.3 }
50 }
50 }
51
51
52 ScatterSeries {
52 ScatterSeries {
53 name: "scatter series"
53 name: "scatter series"
54 axisX: axisX
54 axisX: axisX
55 axisY: axisY
55 axisY: axisY
56 XYPoint { x: 0; y: 0 }
56 XYPoint { x: 0; y: 0 }
57 XYPoint { x: 1.1; y: 2.1 }
57 XYPoint { x: 1.1; y: 2.1 }
58 XYPoint { x: 1.9; y: 3.3 }
58 XYPoint { x: 1.9; y: 3.3 }
59 XYPoint { x: 2.1; y: 2.1 }
59 XYPoint { x: 2.1; y: 2.1 }
60 XYPoint { x: 2.9; y: 4.9 }
60 XYPoint { x: 2.9; y: 4.9 }
61 XYPoint { x: 3.4; y: 3.0 }
61 XYPoint { x: 3.4; y: 3.0 }
62 XYPoint { x: 4.1; y: 3.3 }
62 XYPoint { x: 4.1; y: 3.3 }
63 }
63 }
64 }
64 }
@@ -1,71 +1,71
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "user defined axes"
26 title: "user defined axes"
27
27
28 ValuesAxis {
28 ValueAxis {
29 id: axisX
29 id: axisX
30 min: 0
30 min: 0
31 max: 10
31 max: 10
32 // TODO: property to fix orientation to "X" to make this the X default axis for all series
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
33 // that don't have user defined X axis
34 }
34 }
35
35
36 ValuesAxis {
36 ValueAxis {
37 id: axisY
37 id: axisY
38 min: 0
38 min: 0
39 max: 5
39 max: 5
40 // TODO: property to fix orientation to "Y" to make this the Y default axis for all series
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
41 // that don't have user defined Y axis
42 }
42 }
43
43
44 LineSeries {
44 LineSeries {
45 name: "line series"
45 name: "line series"
46 XYPoint { x: 0; y: 0 }
46 XYPoint { x: 0; y: 0 }
47 XYPoint { x: 1.1; y: 2.1 }
47 XYPoint { x: 1.1; y: 2.1 }
48 XYPoint { x: 1.9; y: 3.3 }
48 XYPoint { x: 1.9; y: 3.3 }
49 XYPoint { x: 2.1; y: 2.1 }
49 XYPoint { x: 2.1; y: 2.1 }
50 XYPoint { x: 2.9; y: 4.9 }
50 XYPoint { x: 2.9; y: 4.9 }
51 XYPoint { x: 3.4; y: 3.0 }
51 XYPoint { x: 3.4; y: 3.0 }
52 XYPoint { x: 4.1; y: 3.3 }
52 XYPoint { x: 4.1; y: 3.3 }
53 }
53 }
54
54
55 ScatterSeries {
55 ScatterSeries {
56 name: "scatter series"
56 name: "scatter series"
57 id: scatter
57 id: scatter
58 XYPoint { x: 0; y: 0 }
58 XYPoint { x: 0; y: 0 }
59 XYPoint { x: 1.1; y: 2.1 }
59 XYPoint { x: 1.1; y: 2.1 }
60 XYPoint { x: 1.9; y: 3.3 }
60 XYPoint { x: 1.9; y: 3.3 }
61 XYPoint { x: 2.1; y: 2.1 }
61 XYPoint { x: 2.1; y: 2.1 }
62 XYPoint { x: 2.9; y: 4.9 }
62 XYPoint { x: 2.9; y: 4.9 }
63 XYPoint { x: 3.4; y: 3.0 }
63 XYPoint { x: 3.4; y: 3.0 }
64 XYPoint { x: 4.1; y: 3.3 }
64 XYPoint { x: 4.1; y: 3.3 }
65 }
65 }
66
66
67 Component.onCompleted: {
67 Component.onCompleted: {
68 // You can also set the axes dynamically
68 // You can also set the axes dynamically
69 chartView.setAxisX(axisX, scatter);
69 chartView.setAxisX(axisX, scatter);
70 }
70 }
71 }
71 }
@@ -1,84 +1,84
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 title: "series specific dynamic axes"
25 title: "series specific dynamic axes"
26 id: chartView
26 id: chartView
27 property int index: 0
27 property int index: 0
28
28
29 Timer {
29 Timer {
30 interval: 1000
30 interval: 1000
31 repeat: true
31 repeat: true
32 running: true
32 running: true
33 onTriggered: {
33 onTriggered: {
34 switch (index) {
34 switch (index) {
35 case 0:
35 case 0:
36 lineAxisX.max = 5;
36 lineAxisX.max = 5;
37 lineAxisY.max = 5;
37 lineAxisY.max = 5;
38 scatterAxisX.max = 10;
38 scatterAxisX.max = 10;
39 scatterAxisY.max = 10;
39 scatterAxisY.max = 10;
40 break;
40 break;
41 case 1:
41 case 1:
42 lineAxisX.max = 10;
42 lineAxisX.max = 10;
43 lineAxisY.max = 10;
43 lineAxisY.max = 10;
44 scatterAxisX.max = 5;
44 scatterAxisX.max = 5;
45 scatterAxisY.max = 5;
45 scatterAxisY.max = 5;
46 break;
46 break;
47 default:
47 default:
48 chartView.axisX().max = 2;
48 chartView.axisX().max = 2;
49 chartView.axisY().max = 2;
49 chartView.axisY().max = 2;
50 }
50 }
51 index = (index + 1) % 3;
51 index = (index + 1) % 3;
52 }
52 }
53 }
53 }
54
54
55 LineSeries {
55 LineSeries {
56 id: lineSeries
56 id: lineSeries
57 name: "line series"
57 name: "line series"
58 axisX: ValuesAxis { id: lineAxisX }
58 axisX: ValueAxis { id: lineAxisX }
59 axisY: ValuesAxis { id: lineAxisY }
59 axisY: ValueAxis { id: lineAxisY }
60
60
61 XYPoint { x: 0; y: 0 }
61 XYPoint { x: 0; y: 0 }
62 XYPoint { x: 1.1; y: 2.1 }
62 XYPoint { x: 1.1; y: 2.1 }
63 XYPoint { x: 1.9; y: 3.3 }
63 XYPoint { x: 1.9; y: 3.3 }
64 XYPoint { x: 2.1; y: 2.1 }
64 XYPoint { x: 2.1; y: 2.1 }
65 XYPoint { x: 2.9; y: 4.9 }
65 XYPoint { x: 2.9; y: 4.9 }
66 XYPoint { x: 3.4; y: 3.0 }
66 XYPoint { x: 3.4; y: 3.0 }
67 XYPoint { x: 4.1; y: 3.3 }
67 XYPoint { x: 4.1; y: 3.3 }
68 }
68 }
69
69
70 ScatterSeries {
70 ScatterSeries {
71 id: scatterSeries
71 id: scatterSeries
72 name: "scatter series"
72 name: "scatter series"
73 axisX: ValuesAxis { id: scatterAxisX }
73 axisX: ValueAxis { id: scatterAxisX }
74 axisY: ValuesAxis { id: scatterAxisY }
74 axisY: ValueAxis { id: scatterAxisY }
75
75
76 XYPoint { x: 0; y: 0 }
76 XYPoint { x: 0; y: 0 }
77 XYPoint { x: 1.1; y: 2.1 }
77 XYPoint { x: 1.1; y: 2.1 }
78 XYPoint { x: 1.9; y: 3.3 }
78 XYPoint { x: 1.9; y: 3.3 }
79 XYPoint { x: 2.1; y: 2.1 }
79 XYPoint { x: 2.1; y: 2.1 }
80 XYPoint { x: 2.9; y: 4.9 }
80 XYPoint { x: 2.9; y: 4.9 }
81 XYPoint { x: 3.4; y: 3.0 }
81 XYPoint { x: 3.4; y: 3.0 }
82 XYPoint { x: 4.1; y: 3.3 }
82 XYPoint { x: 4.1; y: 3.3 }
83 }
83 }
84 }
84 }
@@ -1,64 +1,64
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "switching axes dynamically"
26 title: "switching axes dynamically"
27
27
28 Timer {
28 Timer {
29 interval: 1000
29 interval: 1000
30 repeat: true
30 repeat: true
31 running: true
31 running: true
32 onTriggered: {
32 onTriggered: {
33 if (lineSeries.axisX == valuesAxis1)
33 if (lineSeries.axisX == valueAxis1)
34 lineSeries.axisX = valuesAxis2;
34 lineSeries.axisX = valueAxis2;
35 else
35 else
36 lineSeries.axisX = valuesAxis1;
36 lineSeries.axisX = valueAxis1;
37 }
37 }
38 }
38 }
39
39
40 ValuesAxis {
40 ValueAxis {
41 id: valuesAxis1
41 id: valueAxis1
42 min: 0
42 min: 0
43 max: 5
43 max: 5
44 }
44 }
45
45
46 ValuesAxis {
46 ValueAxis {
47 id: valuesAxis2
47 id: valueAxis2
48 min: 1
48 min: 1
49 max: 6
49 max: 6
50 }
50 }
51
51
52 LineSeries {
52 LineSeries {
53 id: lineSeries
53 id: lineSeries
54 name: "line series"
54 name: "line series"
55 axisX: valuesAxis1
55 axisX: valueAxis1
56 XYPoint { x: 0; y: 0 }
56 XYPoint { x: 0; y: 0 }
57 XYPoint { x: 1.1; y: 2.1 }
57 XYPoint { x: 1.1; y: 2.1 }
58 XYPoint { x: 1.9; y: 3.3 }
58 XYPoint { x: 1.9; y: 3.3 }
59 XYPoint { x: 2.1; y: 2.1 }
59 XYPoint { x: 2.1; y: 2.1 }
60 XYPoint { x: 2.9; y: 4.9 }
60 XYPoint { x: 2.9; y: 4.9 }
61 XYPoint { x: 3.4; y: 3.0 }
61 XYPoint { x: 3.4; y: 3.0 }
62 XYPoint { x: 4.1; y: 3.3 }
62 XYPoint { x: 4.1; y: 3.3 }
63 }
63 }
64 }
64 }
@@ -1,110 +1,110
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 import QtQuick 1.0
21 import QtQuick 1.0
22 import QtCommercial.Chart 1.0
22 import QtCommercial.Chart 1.0
23
23
24 ChartView {
24 ChartView {
25 id: chartView
25 id: chartView
26 title: "Chart Title"
26 title: "Chart Title"
27 anchors.fill: parent
27 anchors.fill: parent
28 property variant series: chartView
28 property variant series: chartView
29
29
30 LineSeries {
30 LineSeries {
31 name: "line"
31 name: "line"
32 XYPoint { x: 0; y: 0 }
32 XYPoint { x: 0; y: 0 }
33 XYPoint { x: 1.1; y: 2.1 }
33 XYPoint { x: 1.1; y: 2.1 }
34 XYPoint { x: 1.9; y: 3.3 }
34 XYPoint { x: 1.9; y: 3.3 }
35 XYPoint { x: 2.1; y: 2.1 }
35 XYPoint { x: 2.1; y: 2.1 }
36 XYPoint { x: 2.9; y: 4.9 }
36 XYPoint { x: 2.9; y: 4.9 }
37 XYPoint { x: 3.4; y: 3.0 }
37 XYPoint { x: 3.4; y: 3.0 }
38 XYPoint { x: 4.1; y: 3.3 }
38 XYPoint { x: 4.1; y: 3.3 }
39 }
39 }
40
40
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
41 onVisibleChanged: console.log("chart.onVisibleChanged: " + visible);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
42 onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
43 onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
44 onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled);
45 onTopMarginChanged: {
45 onTopMarginChanged: {
46 console.log("chart.onTopMarginChanged: " + margin);
46 console.log("chart.onTopMarginChanged: " + margin);
47 marginVisualizer.opacity = 1.0;
47 marginVisualizer.opacity = 1.0;
48 }
48 }
49 onBottomMarginChanged: {
49 onBottomMarginChanged: {
50 console.log("chart.onBottomMarginChanged: " + margin);
50 console.log("chart.onBottomMarginChanged: " + margin);
51 marginVisualizer.opacity = 1.0;
51 marginVisualizer.opacity = 1.0;
52 }
52 }
53 onLeftMarginChanged: {
53 onLeftMarginChanged: {
54 console.log("chart.onLeftMarginChanged: " + margin);
54 console.log("chart.onLeftMarginChanged: " + margin);
55 marginVisualizer.opacity = 1.0;
55 marginVisualizer.opacity = 1.0;
56 }
56 }
57 onRightMarginChanged: {
57 onRightMarginChanged: {
58 console.log("chart.onRightMarginChanged: " + margin);
58 console.log("chart.onRightMarginChanged: " + margin);
59 marginVisualizer.opacity = 1.0;
59 marginVisualizer.opacity = 1.0;
60 }
60 }
61
61
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
62 legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
63 legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
64 legend.onColorChanged: console.log("legend.onColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
65 legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
66 legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color);
67
67
68
68
69 ValuesAxis{
69 ValueAxis{
70 onColorChanged: console.log("axisX.onColorChanged: " + color);
70 onColorChanged: console.log("axisX.onColorChanged: " + color);
71 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
71 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
72 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
72 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
73 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
73 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
74 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
74 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
75 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
75 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
76 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
76 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
77 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
77 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
78 onMinChanged: console.log("axisX.onMinChanged: " + min);
78 onMinChanged: console.log("axisX.onMinChanged: " + min);
79 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
79 onMaxChanged: console.log("axisX.onMaxChanged: " + max);
80 }
80 }
81
81
82 ValuesAxis{
82 ValueAxis{
83 onColorChanged: console.log("axisY.onColorChanged: " + color);
83 onColorChanged: console.log("axisY.onColorChanged: " + color);
84 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
84 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
85 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
85 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
86 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
86 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
87 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
87 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
88 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
88 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
89 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
89 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
90 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
90 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
91 onMinChanged: console.log("axisY.onMinChanged: " + min);
91 onMinChanged: console.log("axisY.onMinChanged: " + min);
92 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
92 onMaxChanged: console.log("axisY.onMaxChanged: " + max);
93 }
93 }
94
94
95 Rectangle {
95 Rectangle {
96 id: marginVisualizer
96 id: marginVisualizer
97 color: "transparent"
97 color: "transparent"
98 border.color: "red"
98 border.color: "red"
99 anchors.fill: parent
99 anchors.fill: parent
100 anchors.topMargin: parent.topMargin
100 anchors.topMargin: parent.topMargin
101 anchors.bottomMargin: parent.bottomMargin
101 anchors.bottomMargin: parent.bottomMargin
102 anchors.leftMargin: parent.leftMargin
102 anchors.leftMargin: parent.leftMargin
103 anchors.rightMargin: parent.rightMargin
103 anchors.rightMargin: parent.rightMargin
104 opacity: 0.0
104 opacity: 0.0
105 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
105 onOpacityChanged: if (opacity > 0.9) opacity = 0.0;
106 Behavior on opacity {
106 Behavior on opacity {
107 NumberAnimation { duration: 800 }
107 NumberAnimation { duration: 800 }
108 }
108 }
109 }
109 }
110 }
110 }
General Comments 0
You need to be logged in to leave comments. Login now