|
@ -5,12 +5,12 @@ function pointFromGeoJSON(geo) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function showBatteryGraph(response) { |
|
|
function showBatteryGraph(response) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var data = response.linestring; |
|
|
var data = response.linestring; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var batteryStateBands = []; |
|
|
var batteryStateBands = []; |
|
|
var buckets = data.properties.map(function(d){return d.battery_state}).findRanges(); |
|
|
var buckets = data.properties.map(function(d){return d.battery_state}).findRanges(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(var i in buckets) { |
|
|
for(var i in buckets) { |
|
|
for(var j=0; j<buckets[i].length; j++) { |
|
|
for(var j=0; j<buckets[i].length; j++) { |
|
|
switch(i) { |
|
|
switch(i) { |
|
@ -32,7 +32,7 @@ function showBatteryGraph(response) { |
|
|
batteryStateBands.push(buckets[i][j]); |
|
|
batteryStateBands.push(buckets[i][j]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#battery-chart').highcharts({ |
|
|
$('#battery-chart').highcharts({ |
|
|
chart: { |
|
|
chart: { |
|
|
height: 160, |
|
|
height: 160, |
|
@ -94,8 +94,8 @@ function showBatteryGraph(response) { |
|
|
yAxis: 0, |
|
|
yAxis: 0, |
|
|
data: data.properties.map(function(d,i){ |
|
|
data: data.properties.map(function(d,i){ |
|
|
return { |
|
|
return { |
|
|
x: new Date(d.unixtime*1000), // i,
|
|
|
|
|
|
y: ('battery_level' in d ? Math.round(d.battery_level * 100) : -1), |
|
|
|
|
|
|
|
|
x: new Date(d.unixtime*1000), // i,
|
|
|
|
|
|
y: ('battery_level' in d ? Math.round(d.battery_level * 100) : null), |
|
|
state: d.battery_state, |
|
|
state: d.battery_state, |
|
|
location: data.coordinates[i] |
|
|
location: data.coordinates[i] |
|
|
} |
|
|
} |
|
|