dissertation/where_fi/visualise/static/plot.js
Christos Falas 4f7a9d2e70
Make into package
Add CLI to bin, allow for tab-completions
2025-01-27 15:55:17 +00:00

43 lines
831 B
JavaScript

const plotElement = document.getElementById("plot");
const layout = {
title: "Real-Time Complex Data Visualization",
xaxis: { title: "Time (ms)" },
yaxis: { title: "Value" },
};
Plotly.newPlot(
plotElement,
[
{
x: [],
y: [],
type: "scatter",
mode: "lines+markers", // Line + markers
},
],
layout,
);
const socket = new WebSocket("ws://" + location.host + "/data");
socket.onopen = function () {
console.log("Connected to the server");
socket.send("0 0 0");
};
socket.addEventListener("message", function (msg) {
Plotly.extendTraces(
plotElement,
{
x: [[msg.timeStamp]],
y: [[msg.data]],
},
[0],
300,
);
});
function changeSubcarrier() {
const subcarrier = document.getElementById("subcarrier").value;
socket.send(subcarrier + " 0 0");
}