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("licht").innerHTML = SensorValues[2];
|
||||
|
||||
Plotly.newPlot('tempGraph', [{
|
||||
y: tempArray,
|
||||
|
||||
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'}
|
||||
}]);
|
||||
|
||||
plotly(tempGraph, tempArray)
|
||||
plotly(humidGraph, humidArray)
|
||||
plotly(lightGraph, lichtArray)
|
||||
}
|
||||
|
||||
// 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
|
||||
async function disconnect() {
|
||||
await reader.cancel();
|
||||
await port.close();
|
||||
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