# JSROOT rendering differs from browser to browser

**URL:** <https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215>\
**Category:** Newbie\
**Tags:** jsroot\
**Created:** [November 22, 2023, 5:00pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215 "2023-11-22T17:00:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkireyeu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/a8b319/32.png) [@vkireyeu](https://root-forum.cern.ch/u/vkireyeu)\
**Post date:** [November 22, 2023, 5:00pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/1 "2023-11-22T17:00:15Z")

</div>

Hi! I have this MWE:

> **Summary**
>
> ```html
> <!DOCTYPE html>
> <html lang="en">
> <head>
> <meta charset="utf-8">
> <title>Test</title>
> </head>
> <body>
> <div id="drawing" style="width:800px; height:600px"></div>
> </body>
> <script type='module'>
> import { openFile, draw, create, createTGraph, createHistogram } from 'https://root.cern/js/7.5.2/modules/main.mjs';
> 
> function CreateLegendEntry(obj, lbl, opt) {
> let entry = create('TLegendEntry');
> entry.fObject = obj;
> entry.fLabel = lbl;
> entry.fOption = opt;
> return entry;
> }
> 
> let file0 = await openFile("https://root.cern/js/files/hsimple.root");
> let file1 = await openFile("https://root.cern/js/files/fillrandom.root");
> 
> let h__file0 = await file0.readObject("hpx");
> let h__file1 = await file1.readObject("h1f");
> 
> h__file0.fLineColor = 1;
> h__file1.fLineColor = 2;
> 
> h__file0.fLineWidth = 4;
> h__file1.fLineWidth = 4;
> 
> const npoints = 5;
> let xpts=[-5, -2, 0, 2, 5];
> let ypts=[20, 50, 100, 45, 15];
> let exp_data = createTGraph(npoints, xpts, ypts);
> exp_data.fMarkerSize = 1.5;
> exp_data.fMarkerStyle = 20;
> 
> let h1 = createHistogram('TH1I', 20);
> h1.fName = 'axis_draw';
> h1.fTitle = "Title";
> h1.fXaxis.fTitle = "Xaxis";
> h1.fYaxis.fTitle = "Yaxis";
> h1.fYaxis.fXmin = 0;
> h1.fYaxis.fXmax = 150;
> h1.fXaxis.fXmin = -10;
> h1.fXaxis.fXmax = 10;
> draw("drawing", h1, "NOSTAT");
> 
> draw("drawing", h__file0, "C same");
> draw("drawing", h__file1, "C same");
> draw("drawing", exp_data, "P");
> let leg = create('TLegend');
> Object.assign(leg, { fX1NDC: 0.2, fY1NDC: 0.75, fX2NDC: 0.6, fY2NDC: 0.9 });
> leg.fPrimitives.Add(CreateLegendEntry(h__file0, 'hpx', 'L'));
> leg.fPrimitives.Add(CreateLegendEntry(h__file1, 'h1f', 'L'));
> leg.fPrimitives.Add(CreateLegendEntry(exp_data, 'data', 'P'));
> 
> draw("drawing", leg);
> </script>
> </html>
> 
> ```

This is how it renders in Safari:

> **Summary**
>
> ![jsroot_safari](https://root-forum.cern.ch/uploads/default/original/3X/f/5/f572e00f24601d14674c5e438ce2d934279a7fcd.jpeg)

And this is in Firefox:

> **Summary**
>
> ![jsroot_firefox](https://root-forum.cern.ch/uploads/default/original/3X/7/f/7f06ec5e1bf405c8f75e7ae536dc63051d44fb34.jpeg)

So, how to ask JSROOT to always make the same results?

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 22, 2023, 6:04pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/2 "2023-11-22T18:04:54Z")

</div>

Hi,

Can you check developer console in Safari?  
Seems to be some failure happens there - which prevent JSROOT from drawing histogram axes.

Unfortunately, JSROOT is not tested with Safari and therefore such kinds of errors may appear.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![vkireyeu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/a8b319/32.png) [@vkireyeu](https://root-forum.cern.ch/u/vkireyeu)\
**Post date:** [November 22, 2023, 6:20pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/3 "2023-11-22T18:20:04Z")

</div>

Hi!

Just checked, but there are no errors in the Safari console except some minor about favicon:

> Not allowed to load local resource: file:///favicon.ico

I also asked my colleague to check this MWE.  
So, I have Firefox 119 and 120 on MacOS and Linux respectively – the result is like on the picture in the first post. My colleague has Firefox 115 and TLegend is missing in that case.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 22, 2023, 6:35pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/4 "2023-11-22T18:35:49Z")

</div>

It is bug in JSROOT. You should see it in the browser console.  
I will fix it in next 7.5.3 version.

For the moment just set fName for TLegend:

```auto
 let leg = create('TLegend');
 Object.assign(leg, { fX1NDC: 0.2, fY1NDC: 0.75, fX2NDC: 0.6, fY2NDC: 0.9, fName: 'TPave' });

```

By mistake it was marked as title.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 22, 2023, 6:47pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/5 "2023-11-22T18:47:33Z")

</div>

There is also another problem which I did not recognize from the beginning.

You should wait until drawing is performed for each object. Most easy way:

```auto
      await draw("drawing", h1, "NOSTAT");
      await draw("drawing", h__file0, "C same");
      await draw("drawing", h__file1, "C same");
      await draw("drawing", exp_data, "P");
      let leg = create('TLegend');
      Object.assign(leg, { fX1NDC: 0.2, fY1NDC: 0.75, fX2NDC: 0.6, fY2NDC: 0.9, fName: 'TPave' });
      leg.fPrimitives.Add(CreateLegendEntry(h__file0, 'hpx', 'L'));
      leg.fPrimitives.Add(CreateLegendEntry(h__file1, 'h1f', 'L'));
      leg.fPrimitives.Add(CreateLegendEntry(exp_data, 'data', 'P'));
      await draw("drawing", leg);

```

---

<div class="post-metadata">

**Author:** ![vkireyeu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/a8b319/32.png) [@vkireyeu](https://root-forum.cern.ch/u/vkireyeu)\
**Post date:** [November 22, 2023, 7:14pm UTC](https://root-forum.cern.ch/t/jsroot-rendering-differs-from-browser-to-browser/57215/6 "2023-11-22T19:14:34Z")

</div>

Thank you! `await` fixed the behaviour for Safari.
