|
|
|
@ -158,6 +158,15 @@ function threeDlineGraph(type, xChartData, yChartData, zChartData) {
|
|
|
|
|
graph: graph
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
new Rickshaw.Graph.HoverDetail({
|
|
|
|
|
graph: graph,
|
|
|
|
|
formatter: function (series, x, y) {
|
|
|
|
|
var date = '<span class="date">' + moment(x * 1000).format('Do MMM YYYY h:mm:ss a') + '</span>';
|
|
|
|
|
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
|
|
|
|
|
return swatch + series.name + ": " + parseInt(y) + '<br>' + date;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
graph.render();
|
|
|
|
|
|
|
|
|
|
return graph;
|
|
|
|
@ -234,58 +243,61 @@ function connect(target) {
|
|
|
|
|
if (ws) {
|
|
|
|
|
ws.onmessage = function (event) {
|
|
|
|
|
var dataPoint = JSON.parse(event.data);
|
|
|
|
|
|
|
|
|
|
if (dataPoint) {
|
|
|
|
|
var time = parseInt(dataPoint[4]) / 1000;
|
|
|
|
|
switch (dataPoint[typeId]) {
|
|
|
|
|
case "battery":
|
|
|
|
|
graphUpdate(batteryData, time, dataPoint[batteryId], graphMap["battery"]);
|
|
|
|
|
graphUpdate(batteryData, time, dataPoint[batteryId]);
|
|
|
|
|
graphMap["battery"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "light":
|
|
|
|
|
graphUpdate(lightData, time, dataPoint[lightId], graphMap["light"]);
|
|
|
|
|
graphUpdate(lightData, time, dataPoint[lightId]);
|
|
|
|
|
graphMap["light"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "pressure":
|
|
|
|
|
graphUpdate(pressureData, time, dataPoint[pressureId], graphMap["pressure"]);
|
|
|
|
|
graphUpdate(pressureData, time, dataPoint[pressureId]);
|
|
|
|
|
graphMap["pressure"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "proximity":
|
|
|
|
|
graphUpdate(proximityData, time, dataPoint[proximityId], graphMap["proximity"]);
|
|
|
|
|
graphUpdate(proximityData, time, dataPoint[proximityId]);
|
|
|
|
|
graphMap["proximity"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "accelerometer":
|
|
|
|
|
dataUpdate(accelerometer_xData, time, dataPoint[accelerometer_xId]);
|
|
|
|
|
dataUpdate(accelerometer_yData, time, dataPoint[accelerometer_yId]);
|
|
|
|
|
dataUpdate(accelerometer_zData, time, dataPoint[accelerometer_zId]);
|
|
|
|
|
graphUpdate(accelerometer_xData, time, dataPoint[accelerometer_xId]);
|
|
|
|
|
graphUpdate(accelerometer_yData, time, dataPoint[accelerometer_yId]);
|
|
|
|
|
graphUpdate(accelerometer_zData, time, dataPoint[accelerometer_zId]);
|
|
|
|
|
graphMap["accelerometer"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "magnetic":
|
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[magnetic_xId]);
|
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[magnetic_yId]);
|
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[magnetic_zId]);
|
|
|
|
|
graphUpdate(magnetic_xData, time, dataPoint[magnetic_xId]);
|
|
|
|
|
graphUpdate(magnetic_yData, time, dataPoint[magnetic_yId]);
|
|
|
|
|
graphUpdate(magnetic_zData, time, dataPoint[magnetic_zId]);
|
|
|
|
|
graphMap["magnetic"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "gyroscope":
|
|
|
|
|
dataUpdate(gyroscope_xData, time, dataPoint[gyroscope_xId]);
|
|
|
|
|
dataUpdate(gyroscope_yData, time, dataPoint[gyroscope_yId]);
|
|
|
|
|
dataUpdate(gyroscope_zData, time, dataPoint[gyroscope_zId]);
|
|
|
|
|
graphUpdate(gyroscope_xData, time, dataPoint[gyroscope_xId]);
|
|
|
|
|
graphUpdate(gyroscope_yData, time, dataPoint[gyroscope_yId]);
|
|
|
|
|
graphUpdate(gyroscope_zData, time, dataPoint[gyroscope_zId]);
|
|
|
|
|
graphMap["gyroscope"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "rotation":
|
|
|
|
|
dataUpdate(magnetic_xData, time, dataPoint[rotation_xId]);
|
|
|
|
|
dataUpdate(magnetic_yData, time, dataPoint[rotation_yId]);
|
|
|
|
|
dataUpdate(magnetic_zData, time, dataPoint[rotation_zId]);
|
|
|
|
|
graphUpdate(magnetic_xData, time, dataPoint[rotation_xId]);
|
|
|
|
|
graphUpdate(magnetic_yData, time, dataPoint[rotation_yId]);
|
|
|
|
|
graphUpdate(magnetic_zData, time, dataPoint[rotation_zId]);
|
|
|
|
|
graphMap["rotation"].update();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "gravity":
|
|
|
|
|
dataUpdate(gravity_xData, time, dataPoint[gravity_xId]);
|
|
|
|
|
dataUpdate(gravity_yData, time, dataPoint[gravity_yId]);
|
|
|
|
|
dataUpdate(gravity_zData, time, dataPoint[gravity_zId]);
|
|
|
|
|
graphUpdate(gravity_xData, time, dataPoint[gravity_xId]);
|
|
|
|
|
graphUpdate(gravity_yData, time, dataPoint[gravity_yId]);
|
|
|
|
|
graphUpdate(gravity_zData, time, dataPoint[gravity_zId]);
|
|
|
|
|
graphMap["gravity"].update();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -294,16 +306,7 @@ function connect(target) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function graphUpdate(chartData, xValue, yValue, graph) {
|
|
|
|
|
chartData.push({
|
|
|
|
|
x: parseInt(xValue),
|
|
|
|
|
y: parseFloat(yValue)
|
|
|
|
|
});
|
|
|
|
|
chartData.shift();
|
|
|
|
|
graph.update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dataUpdate(chartData, xValue, yValue) {
|
|
|
|
|
function graphUpdate(chartData, xValue, yValue) {
|
|
|
|
|
chartData.push({
|
|
|
|
|
x: parseInt(xValue),
|
|
|
|
|
y: parseFloat(yValue)
|
|
|
|
|