JSROOT - axis stuck after unzoom

Dear ROOTers,
I’m currently using JSROOT to display a histogram in a web browser. The histogram is generated by a small section of python code executed by the webserver and passed as a JSON string to a JSROOT.redraw call

python:

hist = ROOT.TH2D("hist", blablablablabla)
for data in bufferToPlot:
    hist.Fill( data[0], data[1] )
jsonResp = ROOT.TBufferJSON.ConvertToJSON(hist)
return jsonResp #this goes back as POST response

Javascript:

  $.post(
    url,
    dat,
    function(data) {
      dataToPlot = data;
      var obj = JSROOT.parse( dataToPlot );
      JSROOT.redraw("ltmondrawing", obj, "colz");
    }
  );

The problem I’m facing is that when I request the first plot everything is fine, then I zoom the y axis, and unzoom it, then request another plot, which will have a different y axis range, but in the browser window the y axis is still the first plot one (see attachment).

Cheers,
Valerio

Plot 1:

Plot 2:

Plot 2 after zoom/unzoom of Plot 1 y axis:

I think @linev can help.

Hi,

JSROOT.redraw() should be used if you intend to redraw same histogram preserving some interactive settings (like zoomed range). If you want to draw new histogram in the same div, just do:

JSROOT.cleanup("ltmondrawing");
JSROOT.draw("ltmondrawing", obj, "colz");

Regards,
Sergey

Thanks Sergey! Exactly what I needed!

btw, I’m having difficulties finding documentation for all the possible actions available in JSROOT. Can you point me in some general direction, if any?

Cheers,
Valerio

Hi Valerio,

Short info you can find here:

Regards,
Sergey

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.