Hi, Let’s say I want to do a 100% custom UI in HTM+CSS+JS with JSROOT, and load data from a server. I would like to auto refresh the display every second in the case data has changed, with some basic polling:
This works:
<html>
<body>
<div id="container" style="width:600px; height:400px; border:1px solid gray;"></div>
<script type='module'>
import { httpRequest, draw } from 'https://root.cern/js/latest/modules/main.mjs';
const drawNow = () => {
document.getElementById("container").innerHTML = "";
httpRequest("http://localhost:8080/graph1/Graph/root.json", "object").then((obj) => { return draw("container", obj, "colz"); });
}
const refresh = () => { // basic polling
drawNow();
setTimeout(refresh, 1000);
}
refresh();
</script>
</body>
</html>
but document.getElementById("container").innerHTML = ""
causes a white screen flickering. On the other hand, if I don’t “clear” like this, the new data points are overwritten on the same plot axis, which is not ok either. How to do this properly?
(i.e. clear the data points (but not redraw the axis), and redraw only the new points)
Thanks!