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