Browse Source

display speed in metric or imperial

pull/6/head
Sebastiaan Andeweg 6 years ago
parent
commit
d7d41f8591
2 changed files with 13 additions and 2 deletions
  1. +12
    -2
      compass/public/assets/speed.js
  2. +1
    -0
      compass/resources/views/map.blade.php

+ 12
- 2
compass/public/assets/speed.js View File

@ -2,6 +2,16 @@ function speedSeries(response) {
var data = response.linestring;
var system = {
label: 'mph',
multiplier: 2.23694
};
if(document.getElementById('is-metric').value == true) {
system.label = 'km/h';
system.multiplier = 3.6;
}
var series = {
name: "Speed",
yAxis: 1,
@ -9,7 +19,7 @@ function speedSeries(response) {
animation: true,
pointFormatter: function(){
moveMarkerToPosition(this);
return '<b>'+this.y+'mph</b>';
return '<b>'+this.y+system.label+'</b>';
}
},
lineWidth: 1,
@ -27,7 +37,7 @@ function speedSeries(response) {
series.data = data.properties.map(function(d,i){
return {
x: new Date(d.unixtime*1000),
y: ('speed' in d && d.speed >= 0 ? Math.round(d.speed * 2.23694) : null),
y: ('speed' in d && d.speed >= 0 ? Math.round(d.speed * system.multiplier) : null),
location: data.coordinates[i]
}
});

+ 1
- 0
compass/resources/views/map.blade.php View File

@ -57,6 +57,7 @@
<div id="map"></div>
<div id="graphs">
<input id="is-metric" type="hidden" value="{{ $database->metric }}">
<div id="battery-chart" width="800" height="160"></div>
</div>

Loading…
Cancel
Save