@@ -25,9 +25,9 XmlListModel { | |||||
25 | // Hard-coded test data |
|
25 | // Hard-coded test data | |
26 | xml: "<results><row><speedTrap>0</speedTrap><driver>Fittipaldi</driver><speed>104.12</speed></row>" |
|
26 | xml: "<results><row><speedTrap>0</speedTrap><driver>Fittipaldi</driver><speed>104.12</speed></row>" | |
27 | +"<row><speedTrap>0</speedTrap><driver>Stewart</driver><speed>106.12</speed></row>" |
|
27 | +"<row><speedTrap>0</speedTrap><driver>Stewart</driver><speed>106.12</speed></row>" | |
28 | // ... |
|
|||
29 | //![1] |
|
|||
30 |
|
|
28 | +"<row><speedTrap>0</speedTrap><driver>Hunt</driver><speed>106.12</speed></row>" | |
|
29 | // ... | |||
|
30 | //![1] | |||
31 | +"<row><speedTrap>1</speedTrap><driver>Fittipaldi</driver><speed>115.12</speed></row>" |
|
31 | +"<row><speedTrap>1</speedTrap><driver>Fittipaldi</driver><speed>115.12</speed></row>" | |
32 | +"<row><speedTrap>1</speedTrap><driver>Stewart</driver><speed>114.12</speed></row>" |
|
32 | +"<row><speedTrap>1</speedTrap><driver>Stewart</driver><speed>114.12</speed></row>" | |
33 | +"<row><speedTrap>1</speedTrap><driver>Hunt</driver><speed>115.12</speed></row>" |
|
33 | +"<row><speedTrap>1</speedTrap><driver>Hunt</driver><speed>115.12</speed></row>" |
@@ -64,23 +64,28 Rectangle { | |||||
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; | |||
|
69 | chartView.axisY().title = "speed (kph)"; | |||
|
70 | chartView.axisX().title = "speed trap"; | |||
|
71 | chartView.axisX().labelFormat = "%.0f"; | |||
68 | } |
|
72 | } | |
69 | lineSeries.append(currentIndex, speedsXml.get(currentIndex).speed); |
|
73 | lineSeries.append(speedsXml.get(currentIndex).speedTrap, speedsXml.get(currentIndex).speed); | |
70 |
|
74 | |||
71 | // Make the x-axis range dynamic |
|
75 | if (speedsXml.get(currentIndex).speedTrap > 3) { | |
72 | if (currentIndex > 9) |
|
76 | chartView.axisX().max = Number(speedsXml.get(currentIndex).speedTrap) + 1; | |
73 |
chartView.axisX().min = c |
|
77 | chartView.axisX().min = chartView.axisX().max - 5; | |
74 | else |
|
78 | } else { | |
|
79 | chartView.axisX().max = 5; | |||
75 | chartView.axisX().min = 0; |
|
80 | chartView.axisX().min = 0; | |
76 |
|
81 | } | ||
77 |
chartView.axisX().max |
|
82 | chartView.axisX().tickCount = chartView.axisX().max - chartView.axisX().min + 1; | |
78 | } else { |
|
83 | } else { | |
79 | // 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 | |
80 | timer.stop(); |
|
85 | timer.stop(); | |
81 | chartView.animationOptions = ChartView.AllAnimations; |
|
86 | chartView.animationOptions = ChartView.AllAnimations; | |
82 | chartView.axisX().min = 0; |
|
87 | chartView.axisX().min = 0; | |
83 |
chartView.axisX().max = currentIndex |
|
88 | chartView.axisX().max = speedsXml.get(currentIndex - 1).speedTrap; | |
84 | } |
|
89 | } | |
85 | } |
|
90 | } | |
86 | } |
|
91 | } |
General Comments 0
You need to be logged in to leave comments.
Login now