Rare instance of JSROOT loading a TGraph incorrectly

Using root.cern/js/latest

By chance I discovered that one of my root graphs had one x-value changed when displayed using JSROOT. After a hard reload & clearing the browser caches, the graph was loaded correctly. I saw something similar happen once before, months ago, with a different graph. This time I saved the graph as JSON before and after clearing caches and reloading the page.

In my graphs, all the x-values should be integers so if I inspect the graph it’s fairly easy to spot when one has been replaced by a float. It should also be straightforward for me to add more js code to check the graphs upon loading. This is the problem sequence (the float should be 132382) :

    132380,
    132381,
    132398.34546320408,
    132383,

The graph in question is called ‘rho_mass_and_yield’ and it is contained the multigraph saved in the attached root file. I also attached the JSON files.

Best regards,
Naomi.

after_clearing_cache.json.txt (35.1 KB)

rho_mass_and_yield.json.txt (35.1 KB)

graph.root (7.4 KB)

@linev

Hi Naomi,

Can you provide more information how you display TGraph or TMultiGraph object?
The best - HTML/JavaScript code which shows the effect.

You should be aware that TGraph object has kNotEditable bit and it is off by default.
Means that such TGraph can be modified by any mouse click - after it displayed on the canvas. Same is true for JSROOT.

If you want to prevent TGraph object can be changed - just call gr->SetEditable(kFALSE);

Regards,
Sergey

Hi Sergey,

Thank you for the reminder about kNotEditable. I will fix that.

My code is here . Let me know if you would like me to share a minimalist tar file including the data files.

As my graphs should have integer x-values, I recently added JS code to check this when it loads the graphs. It has not caught any errors yet.

One set of graphs has 1158 values per graph and up to 42 graphs on each web page, is that too much?

Best regards,
Naomi.

Hi Naomi,

You should try to set kNotEditable for the graphs to prevent any interactive changes.

No, it is normal number of graphs/points which can be handled by JSROOT.
But you can try to parallelize loading of the data. When you do it sequentially - you encounter N times latency of the client-server communication. If possible - try to avoid await in the code and just provide Promise handlers.

Something like:

for (const fullgname of graphs_this_page) {
   file.readObject(fullgname).then(rootgraph => {
      // draw graph or multigraph on the div
   }).catch(err => {
      console.log(`Graph ${fullgname} not found in root file`);
      console.error(err);
   });

All necessary <div> elements can be created in advance.

I think you can remove checks of fX values in the TGraph. I pretty sure that JSROOT correctly reads them from the file.

Regards,
Sergey