Running JSROOT From Local Server and setting histogram titles

Hello All,
I am new to root and am trying to draw a histogram using JSROOT. I have a two questions:

  1. Everything works when calling the js files from cern servers, but not from local servers.
    I cloned the repo from jsroot github, am on the main branch, and can individually access the js files (just to ensure that the local server settings works)
 import { openFile } from 'https://root.cern/js/latest/modules/io.mjs';
 import { redraw,draw } from 'https://root.cern/js/latest/modules/draw.mjs';

 // import { openFile } from 'http://server/html/jsroot/modules/io.mjs';
 // import { draw } from 'http://server/html/jsroot/modules/draw.mjs';

How do I use the js files from a local server? I understand this may be more a front-end web question, but just in case someone encountered the same issue. The exact error when calling js files from local server is (from firefox console) is:

Uncaught (in promise) SyntaxError: ambiguous indirect export: setHistTitle

  1. After drawing a histogram, how do you set the labels (title, xlabel, ylabel etc). I am drawing the histogram thusly:
let ntuples = await file.readObject("ntuples;1");
let hist = draw("drawing", ntuples, "px:py:pz");
// hist.fTitle="asfsd"; //This does not work.

Thank you,


ROOT Version: NA jsroot.git master
Platform: Browser
Compiler: NA


Welcome to the ROOT Forum!
I’m sure @linev can help you

Hi,

It should not be a difference if you are using JSROOT from root.cern website or from local.
Error with setHistTitle is strange - such function is not defined in JSROOT. Do you have it in your sources?

About second question - this is not a proper way.
As a result of tree/tuple drawing one gets promise with painter of produced object.
To change title, one should do:

let painter = await draw("drawing", ntuples, "px:py:pz");
painter.getObject().fTitle = "custom title";
painter.redrawPad();

Please try this code.