Skip to content

Commit eb569f0

Browse files
handle packets not having same set of data fields
1 parent 73b710b commit eb569f0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

js/tracker.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,21 @@ function graphAddPosition(idx, new_data) {
14281428
if(i >= 8) return; // up to 8 seperate data plots only
14291429

14301430
if(data[i] === undefined) {
1431+
// when a new data field comes in packet other than the first one
1432+
if(data[0].data.length > 1) {
1433+
var xref = data[0].data;
1434+
1435+
data[i] = {};
1436+
data[i].data = new Array(xref.length);
1437+
1438+
// we intialize it's series entry with empty data
1439+
// all series need to be the same length for slicing to work
1440+
for(var k in xref) {
1441+
data[i].data[k] = [xref[k][9], null];
1442+
}
1443+
}
1444+
1445+
// configure series
14311446
data[i] = {
14321447
label: k + " = 0",
14331448
key: k,
@@ -1439,6 +1454,7 @@ function graphAddPosition(idx, new_data) {
14391454
vehicle.graph_data_map[k] = i;
14401455
data_matrix[i] = [ts, null];
14411456

1457+
// additinal series configuration
14421458
if(isInt(v)) $.extend(true, data[i], { noInterpolate: true, lines: { steps: true }});
14431459
}
14441460

0 commit comments

Comments
 (0)