Hello,
I am implementing a javascript dashboard which every second loads a .ROOT file and draws it in a div:
let isFirstDraw = true;
async function update(){
let file = await JSROOT.openFile(`dashboard/resources/${relPath}`);
let obj = await file.readObject("c");
if (isFirstDraw) {
await JSROOT.draw("drawing", obj);
} else {
await JSROOT.redraw("drawing", obj);
}
isFirstDraw = false;
}
I want the redrawing to persist information such as whether the axes are in log scale, how do I do so?
As part of my tests I tried using draw(dom, obj, "logy")
, which correctly sets the y axis to log scale, however using redraw(dom, obj, "logy")
resets the axis to linear scale. Is this meant to be the case? In general, how do I get settings for the current canvas (obj is a TCanvas) and then update them? For example, I was able to get the logy from:
const canvas = await draw(dom, obj)
const logY = canvas.getObject().fLogy;
but am not sure as to how I’d then update another canvas with this. For example, this is an idea I had, which didn’t work.
Object.assign(canvas.getObject(), {fLogy: logY})
For further information, this is the code that creates the plot:
npoints = data["num_entries"]
graph = ROOT.TGraph(npoints)
for i in range(npoints):
t = data["timestamps"][i].timestamp()
y = data["values"][i]
graph.SetPoint(i, t, y)
c = ROOT.TCanvas("c", "Canvas", 800, 600)
graph.Draw("AP")
xaxis = graph.GetXaxis()
xaxis.SetTimeDisplay(1)
xaxis.SetTimeFormat("%Y-%m-%d %H:%M:%S")
xaxis.SetLabelSize(0.03)
c.Modified()
c.Update()
c.SaveAs(f'{output_file}')
Thanks in advance.
ROOT Version: 6.32.08
Platform: macosxarm64
Compiler: Apple clang 16.0.0