put plotly into a function
This commit is contained in:
@@ -72,25 +72,9 @@ async function readLoop() {
|
|||||||
document.getElementById("humid").innerHTML = SensorValues[1];
|
document.getElementById("humid").innerHTML = SensorValues[1];
|
||||||
document.getElementById("licht").innerHTML = SensorValues[2];
|
document.getElementById("licht").innerHTML = SensorValues[2];
|
||||||
|
|
||||||
Plotly.newPlot('tempGraph', [{
|
plotly(tempGraph, tempArray)
|
||||||
y: tempArray,
|
plotly(humidGraph, humidArray)
|
||||||
|
plotly(lightGraph, lichtArray)
|
||||||
mode: 'lines',
|
|
||||||
line: {color: '#80CAF6'}
|
|
||||||
}]);
|
|
||||||
Plotly.newPlot('humidGraph', [{
|
|
||||||
y: humidArray,
|
|
||||||
|
|
||||||
mode: 'lines',
|
|
||||||
line: {color: '#80CAF6'}
|
|
||||||
}]);
|
|
||||||
Plotly.newPlot('lightGraph', [{
|
|
||||||
y: lichtArray,
|
|
||||||
|
|
||||||
mode: 'lines',
|
|
||||||
line: {color: '#80CAF6'}
|
|
||||||
}]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the received data in the console
|
// Show the received data in the console
|
||||||
@@ -106,14 +90,17 @@ async function readLoop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function plotly(){
|
|
||||||
Plotly.update(tempgraph, {x: [xArray], y: [tempArray] })
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the port
|
// Close the port
|
||||||
async function disconnect() {
|
async function disconnect() {
|
||||||
await reader.cancel();
|
await reader.cancel();
|
||||||
await port.close();
|
await port.close();
|
||||||
console.log("Port is closed!");
|
console.log("Port is closed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function plotly(graph, array){
|
||||||
|
Plotly.newPlot(graph, [{
|
||||||
|
y: array,
|
||||||
|
mode: 'lines',
|
||||||
|
line: {color: '#80CAF6'}
|
||||||
|
}]);
|
||||||
|
}
|
Reference in New Issue
Block a user