# Graphs ## Introduction The graphs are used to display the data from the sensors. The data is collected by the raspberry pi and then displayed on the graphs. The graphs are made using the [plotly library](https://plotly.com/javascript/) . ## Requirements ### Live graphs - Every node has to have a live graph - The graphs has to be updated every 5 seconds - All the data from one node has to fit in one graph ## Class diagrams ### Graphs ```mermaid classDiagram class graph { +nodeId makeGraph() } ``` ### Live graphs ```mermaid classDiagram class liveGraph extends graph { +nodeId +cnt +timeArray +tempArray +humiArray +eco2Array +tvocArray makeGraph() updateGraph() updateData() } ``` ## Order of operations ### Live graphs ```mermaid sequenceDiagram participant Node participant Raspberry pi participant Website Node->>Raspberry pi: sensordata via websocket every 5 seconds Raspberry pi->>Website: Node data via websocket if new data is received from the node Website->>Website: updateGraph() Website->>Website: updateData() ``` 1. Every node sends its data to the raspberry pi via websocket every 5 seconds 2. The raspberry pi sends the data to the website via websocket if new data is received from the node 3. The website updates the data coming from the raspberry pi on its own variables and arrays 4. The website updates the live graphs every time new data is received from the websocket