Skip to content

Commit 03fde5f

Browse files
refresh graph after new data; yaxes min range is 0
yaxes min range --------------- This will make the graph readable, when there is data with a tiny range. However, if the data at any point goes bellow 0, the limit is removed and the axis scales automatically.
1 parent 8524954 commit 03fde5f

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

cache.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# version 52
2+
# version 53
33

44
# gogole maps files
55
http://maps.google.com/maps/api/js?v=3.10&sensor=false&key=AIzaSyCOqkcNey4CCyG4X0X5qxHAhCgD8g5DwXg

js/plot_config.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ var plot_options = {
2121
mode: "x"
2222
},
2323
yaxes: [
24-
{show: false},
25-
{show: false},
26-
{show: false},
27-
{show: false},
28-
{show: false},
29-
{show: false},
30-
{show: false},
31-
{show: false},
32-
{show: false},
33-
{show: false},
34-
{show: false},
35-
{show: false},
24+
{show: false, min: 0 },
25+
{show: false, min: 0 },
26+
{show: false, min: 0 },
27+
{show: false, min: 0 },
28+
{show: false, min: 0 },
29+
{show: false, min: 0 },
30+
{show: false, min: 0 },
31+
{show: false, min: 0 },
32+
{show: false, min: 0 },
3633
],
3734
xaxes: [
3835
{

js/tracker.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ function updateVehicleInfo(index, position) {
412412

413413
$('.portrait .vehicle'+index).html(a + p + b);
414414
$('.landscape .vehicle'+index).html(a + l + b);
415+
416+
// update graph is current vehicles is followed
417+
if(vehicles[index].follow) updateGraph(index);
418+
415419
return true;
416420
}
417421

@@ -792,23 +796,27 @@ function graphAddLastPosition(idx) {
792796
var ts = (new Date(new_data.gps_time)).getTime(); // flot needs miliseconds for time
793797
var series_idx = 1;
794798

799+
// altitude is always the first series
795800
if(data[0] === undefined) {
796801
data[0] = {
797802
label: "altitude = 0",
798803
color: '#33B5E5',
799-
yaxis: 1,
804+
yaxis: series_idx,
800805
lines: { show:true, fill: true, fillColor: "rgba(51, 181, 229, 0.1)" },
801806
data: []
802807
};
803808
}
804809

805810
// push latest altitude
806811
data[0].data.push([ts, parseInt(new_data.gps_alt)]);
812+
if(parseInt(new_data.gps_alt) < 0) delete plot_options.yaxes[series_idx-1].min;
813+
814+
// the rest of the series is from the data field
807815
var json = $.parseJSON(new_data.data);
808816

809817
$.each(json, function(k, v) {
810-
if(isNaN(v)) return;
811-
if(series_idx > 7) return;
818+
if(isNaN(v)) return; // only take data that is numerical
819+
if(series_idx > 7) return; // up to 7 seperate data plots
812820

813821
var i = series_idx++;
814822

@@ -821,7 +829,8 @@ function graphAddLastPosition(idx) {
821829

822830
if(isInt(v)) $.extend(true, data[i], { noInterpolate: true, lines: { steps: true }});
823831
}
824-
data[i].data.push([ts, parseFloat(v)]);
832+
data[i].data.push([ts, v]);
833+
if(v < 0) delete plot_options.yaxes[i+1].min;
825834
});
826835
}
827836

0 commit comments

Comments
 (0)