##// END OF EJS Templates
Updated QML Weather and QML F1 legends pics
Tero Ahola -
r2349:023e5d4ef689
parent child
Show More
@@ -1,93 +1,93
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.1
22 import QtCommercial.Chart 1.1
23
23
24 Rectangle {
24 Rectangle {
25 width: 360
25 width: 400
26 height: 360
26 height: 300
27 property int currentIndex: -1
27 property int currentIndex: -1
28
28
29 //![1]
29 //![1]
30 ChartView {
30 ChartView {
31 id: chartView
31 id: chartView
32 title: "Driver Speeds, lap 1"
32 title: "Driver Speeds, lap 1"
33 anchors.fill: parent
33 anchors.fill: parent
34 legend.alignment: Qt.AlignTop
34 legend.alignment: Qt.AlignTop
35 animationOptions: ChartView.SeriesAnimations
35 animationOptions: ChartView.SeriesAnimations
36 }
36 }
37 //![1]
37 //![1]
38
38
39 //![2]
39 //![2]
40 // An example XmlListModel containing F1 legend drivers' speeds at speed traps
40 // An example XmlListModel containing F1 legend drivers' speeds at speed traps
41 SpeedsXml {
41 SpeedsXml {
42 id: speedsXml
42 id: speedsXml
43 onStatusChanged: {
43 onStatusChanged: {
44 if (status == XmlListModel.Ready) {
44 if (status == XmlListModel.Ready) {
45 timer.start();
45 timer.start();
46 }
46 }
47 }
47 }
48 }
48 }
49 //![2]
49 //![2]
50
50
51 //![3]
51 //![3]
52 // A timer to mimic refreshing the data dynamically
52 // A timer to mimic refreshing the data dynamically
53 Timer {
53 Timer {
54 id: timer
54 id: timer
55 interval: 700
55 interval: 700
56 repeat: true
56 repeat: true
57 triggeredOnStart: true
57 triggeredOnStart: true
58 running: false
58 running: false
59 onTriggered: {
59 onTriggered: {
60 currentIndex++;
60 currentIndex++;
61 if (currentIndex < speedsXml.count) {
61 if (currentIndex < speedsXml.count) {
62 // Check if there is a series for the data already (we are using driver name to identify series)
62 // Check if there is a series for the data already (we are using driver name to identify series)
63 var lineSeries = chartView.series(speedsXml.get(currentIndex).driver);
63 var lineSeries = chartView.series(speedsXml.get(currentIndex).driver);
64 if (!lineSeries) {
64 if (!lineSeries) {
65 lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver);
65 lineSeries = chartView.createSeries(ChartView.SeriesTypeLine, speedsXml.get(currentIndex).driver);
66 chartView.axisY().min = 0;
66 chartView.axisY().min = 0;
67 chartView.axisY().max = 250;
67 chartView.axisY().max = 250;
68 chartView.axisY().tickCount = 6;
68 chartView.axisY().tickCount = 6;
69 chartView.axisY().titleText = "speed (kph)";
69 chartView.axisY().titleText = "speed (kph)";
70 chartView.axisX().titleText = "speed trap";
70 chartView.axisX().titleText = "speed trap";
71 chartView.axisX().labelFormat = "%.0f";
71 chartView.axisX().labelFormat = "%.0f";
72 }
72 }
73 lineSeries.append(speedsXml.get(currentIndex).speedTrap, speedsXml.get(currentIndex).speed);
73 lineSeries.append(speedsXml.get(currentIndex).speedTrap, speedsXml.get(currentIndex).speed);
74
74
75 if (speedsXml.get(currentIndex).speedTrap > 3) {
75 if (speedsXml.get(currentIndex).speedTrap > 3) {
76 chartView.axisX().max = Number(speedsXml.get(currentIndex).speedTrap) + 1;
76 chartView.axisX().max = Number(speedsXml.get(currentIndex).speedTrap) + 1;
77 chartView.axisX().min = chartView.axisX().max - 5;
77 chartView.axisX().min = chartView.axisX().max - 5;
78 } else {
78 } else {
79 chartView.axisX().max = 5;
79 chartView.axisX().max = 5;
80 chartView.axisX().min = 0;
80 chartView.axisX().min = 0;
81 }
81 }
82 chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1;
82 chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1;
83 } else {
83 } else {
84 // No more data, change x-axis range to show all the data
84 // No more data, change x-axis range to show all the data
85 timer.stop();
85 timer.stop();
86 chartView.animationOptions = ChartView.AllAnimations;
86 chartView.animationOptions = ChartView.AllAnimations;
87 chartView.axisX().min = 0;
87 chartView.axisX().min = 0;
88 chartView.axisX().max = speedsXml.get(currentIndex - 1).speedTrap;
88 chartView.axisX().max = speedsXml.get(currentIndex - 1).speedTrap;
89 }
89 }
90 }
90 }
91 }
91 }
92 //![3]
92 //![3]
93 }
93 }
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now