79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
/**
|
|
* This file defines an horizontal bar chart used in the live tracking page, showing Ublox horizontal accuracy,
|
|
* smartphone horizontal accuracy and distance between the positions of the Ublox
|
|
* and the Smartphone at a same time in meters.
|
|
*
|
|
* @authors Timo Volkmann, Frank Herkommer.
|
|
*/
|
|
|
|
//Defines the chart and its properties.
|
|
let ctx = document.getElementById("accuracy").getContext('2d');
|
|
let barChart = new Chart(ctx, {
|
|
type: 'horizontalBar',
|
|
data: {
|
|
labels: ["Meters"],
|
|
datasets: [{
|
|
label: 'Ublox H. acc.',
|
|
data: [0, 0],
|
|
backgroundColor: "rgba(214, 69, 65, 1)"
|
|
}, {
|
|
label: 'Smartphone H. acc.',
|
|
data: [0, 0],
|
|
backgroundColor: "rgba(30, 139, 195, 1)"
|
|
}, {
|
|
label: 'Dist. Ublox-Smartphone',
|
|
data: [0],
|
|
backgroundColor: "rgba(30, 139, 0, 1)"
|
|
}]
|
|
},
|
|
options: {
|
|
scales: {
|
|
xAxes: [{
|
|
ticks: {
|
|
min: 0,
|
|
max: 10
|
|
}
|
|
}]
|
|
},
|
|
legend: {
|
|
display: true,
|
|
enabled: true
|
|
},
|
|
tooltips: {
|
|
enabled: false,
|
|
display: false
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Function to add the Horizontal and Vertical accuracy sent by the Ublox to the chart.
|
|
* Called every time a message is received over serial connection from the server.
|
|
* @param hacc horizontal accuracy in meters.
|
|
* @param vacc vertical accuracy in meters
|
|
*/
|
|
function addSerialAccuracy(hacc, vacc){
|
|
barChart.data.datasets[0].data = [hacc, vacc];
|
|
barChart.update();
|
|
}
|
|
|
|
/**
|
|
* Function to add the Horizontal and Vertical accuracy sent by the Smartphone to the chart.
|
|
* Called every time a message is received over tcp connection from the server.
|
|
* @param hacc horizontal accuracy in meters.
|
|
* @param vacc vertical accuracy in meters
|
|
*/
|
|
function addTCPAccuracy(hacc, vacc){
|
|
barChart.data.datasets[1].data = [hacc, vacc];
|
|
barChart.update();
|
|
}
|
|
|
|
/**
|
|
* Function to add the calculated distance between coordinates sent by the Ublox and the coordinates
|
|
* sent by the smartphone to the chart.
|
|
* @param dist distance calculated in meters.
|
|
*/
|
|
function addDistanceToBarChart(dist){
|
|
barChart.data.datasets[2].data = [dist];
|
|
barChart.update();
|
|
} |