Skip to content

Commit fb41fd5

Browse files
committed
Updating demos
1 parent 32ce65d commit fb41fd5

File tree

4 files changed

+49
-38
lines changed

4 files changed

+49
-38
lines changed

api.htm

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
355355
<script type="module">
356356
import { httpRequest, version, version_id, source_dir } from './modules/core.mjs';
357357

358-
let jsroot_path = './', filepath = 'https://root.cern/js/files/';
358+
let jsroot_path = './',
359+
filepath = 'https://root.cern/js/files/',
360+
demopath = '';
359361

360362
document.getElementById('version').innerText = version_id != 'dev' ? version_id : version;
361363
document.getElementById('version').title = `${version}, ${source_dir}`;
@@ -374,6 +376,8 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
374376
jsroot_path = 'https://root.cern/js/dev/';
375377
else if (window.location.host.indexOf('jsroot.gsi.de') >= 0)
376378
filepath = 'https://jsroot.gsi.de/files/'
379+
else if (window.location.host.indexOf('localhost') >= 0)
380+
demopath = 'https://root.cern/js/latest/';
377381

378382
function GetGithubBrunch(is_test) {
379383
if (source_dir.indexOf('/dev/') > 0 && !is_test)
@@ -429,15 +433,15 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
429433
{ name: 'Context menu', url: 'demo/context_menu.htm', title: 'Custom context menu for TH2 histograms', src: true },
430434
{ name: 'Zooming', url: 'demo/zoom_handler.htm', title: 'Redefine Zoom function to make synchronous zooming in other histogram', src: true },
431435
{ name: 'User IO', url: `index.htm?file=${filepath}amore.root&item=moH1F_0;1&inject=../demo/amore.mjs`, title: 'Example of custom streamer and custom draw function (AMORE)', src: 'demo/amore.mjs' },
432-
{ name: 'User class', url: 'index.htm?file=demo/custom/divhist.root&inject=demo/custom/divhist.js&item=DivHist', title: 'Example of draw function for custom user class', src: 'demo/custom/divhist.js' },
436+
{ name: 'User class', url: 'index.htm?file=demo/custom/divhist.root&inject=../demo/custom/divhist.mjs&item=DivHist', title: 'Example of draw function for custom user class', src: 'demo/custom/divhist.mjs' },
433437
{ name: 'Store JSON', url: 'demo/store_json.htm', title: 'Store drawn objects into JSON, can be reused to display once again', src: true },
434438
{ name: 'build3d', url: 'demo/build3d.htm', title: 'Example how one can create three.js model for different classes, using generic build3d() function', src: 'demo/build3d.htm' },
435439
{ name: 'Geometry', url: 'demo/tgeo_build.htm', title: 'Example how one can create three.js model for TGeo object, using build() function from geom/TGeoPainter.mjs', src: 'demo/tgeo_build.htm' },
436440
{ name: 'OpenUI5', url: 'demo/openui5/', title: 'Use of JSROOT graphics inside OpenUI5', src: 'demo/openui5/Readme.md' }
437441
],
438442
'TTree': [
439443
{ name: 'TSelector', url: 'demo/read_tree.htm', title: 'Simple example of reading TTree using TSelector class', src: true, syn: 'custom_html_read_tree' },
440-
{ name: 'User class', url: 'index.htm?file=https://root.cern/files/markus.root&item=_Event;1/Refs&opt=dump&inject=demo/gaudi.js', title: 'Example of user custom streamer for reading TTree data (Gaudi)', src: 'demo/gaudi.js', syn: 'custom_html_user_tree' },
444+
{ name: 'User class', url: 'index.htm?file=https://root.cern/files/markus.root&item=_Event;1/Refs&opt=dump&inject=../demo/gaudi.mjs', title: 'Example of user custom streamer for reading TTree data (Gaudi)', src: 'demo/gaudi.js', syn: 'custom_html_user_tree' },
441445
{ name: 'Extract tracks', url: 'index.htm?inject=../demo/alice_esd.mjs&files=[https://root.cern/files/alice_ESDgeometry.root,https://root.cern/files/alice_ESDs.root]&item=[[0]/Gentle;1,[1]/esdTree;1]&opt=[,extract_tracks$]', title: 'Extract tracks from the custom tree', src: 'demo/alice_esd.mjs' }
442446
],
443447
'Node.js': [
@@ -453,36 +457,36 @@ <h1><div><a href="https://root.cern/js/">JSROOT</a></div><a id="version" href="h
453457
],
454458
'httpserver.C' : [
455459
{ link: 'https://github.com/root-project/root/blob/master/tutorials/http/httpserver.C' },
456-
{ name: 'Default page', url: 'httpserver.C/', title: 'Default HTML page of running httpserver.C macro (snapshot)' },
457-
{ name: 'Sub-folder', url: 'httpserver.C/Files/job1.root/', title: 'Browse server objects from sub-folder' },
458-
{ name: 'Display item', url: 'httpserver.C/?item=Files/job1.root/hpxpy&opt=colz&monitoring=1000', title: 'Display histogram and enable monitoring (not updating while snapshot is used)' },
459-
{ name: 'No browser (1)', url: 'httpserver.C/Files/job1.root/hpxpy/draw.htm?opt=colz', title: 'Display item without browser, using provided draw.htm page' },
460-
{ name: 'No browser (2)', url: 'httpserver.C/?nobrowser&item=Files/job1.root/hpxpy&opt=colz', title: 'Display item without browser, using nobrowser option and normal UI' },
461-
{ name: 'Produce PNG', url: 'httpserver.C/Files/job1.root/hpxpy/root.png', title: 'Use normal ROOT drawing to produce PNG image' },
462-
{ name: 'Access object members', url: 'httpserver.C/?item=Canvases/c1/fPrimitives/hpx', title: 'Show histogram from TCanvas lists of primitives (all other objects not cached in this example)' },
463-
{ name: 'Get object title', url: 'httpserver.C/Files/job1.root/hpxpy/exe.json?method=GetTitle', title: 'Access object methods with exe.json request' },
464-
{ name: 'Tree player', url: 'httpserver.C/?item=Files/job1.root/ntuple', title: 'Custom UI to execute TTree::Draw on running application' },
465-
{ name: 'Read file', url: `httpserver.C/?file=${filepath}hsimple.root&layout=grid2x2&items=[hsimple.root/hpx;1,hsimple.root/hpxpy;1,job1/Files/job1.root/hpx,job1/Files/job1.root/hpxpy]&opts=[hist,col,hist,col]`, title: 'Show histograms from ROOT file and THttpServer' },
466-
{ name: 'Superimpose', url: `httpserver.C/?file=${filepath}hsimple.root&item=[job1/Files/job1.root/hpx,hsimple.root/hpx;1]&opt=logy`, title: 'Superimpose objects from ROOT file and online server' }
460+
{ name: 'Default page', url: demopath + 'httpserver.C/', title: 'Default HTML page of running httpserver.C macro (snapshot)' },
461+
{ name: 'Sub-folder', url: demopath + 'httpserver.C/Files/job1.root/', title: 'Browse server objects from sub-folder' },
462+
{ name: 'Display item', url: demopath + 'httpserver.C/?item=Files/job1.root/hpxpy&opt=colz&monitoring=1000', title: 'Display histogram and enable monitoring (not updating while snapshot is used)' },
463+
{ name: 'No browser (1)', url: demopath + 'httpserver.C/Files/job1.root/hpxpy/draw.htm?opt=colz', title: 'Display item without browser, using provided draw.htm page' },
464+
{ name: 'No browser (2)', url: demopath + 'httpserver.C/?nobrowser&item=Files/job1.root/hpxpy&opt=colz', title: 'Display item without browser, using nobrowser option and normal UI' },
465+
{ name: 'Produce PNG', url: demopath + 'httpserver.C/Files/job1.root/hpxpy/root.png', title: 'Use normal ROOT drawing to produce PNG image' },
466+
{ name: 'Access object members', url: demopath + 'httpserver.C/?item=Canvases/c1/fPrimitives/hpx', title: 'Show histogram from TCanvas lists of primitives (all other objects not cached in this example)' },
467+
{ name: 'Get object title', url: demopath + 'httpserver.C/Files/job1.root/hpxpy/exe.json?method=GetTitle', title: 'Access object methods with exe.json request' },
468+
{ name: 'Tree player', url: demopath + 'httpserver.C/?item=Files/job1.root/ntuple', title: 'Custom UI to execute TTree::Draw on running application' },
469+
{ name: 'Read file', url: `${demopath}httpserver.C/?file=${filepath}hsimple.root&layout=grid2x2&items=[hsimple.root/hpx;1,hsimple.root/hpxpy;1,job1/Files/job1.root/hpx,job1/Files/job1.root/hpxpy]&opts=[hist,col,hist,col]`, title: 'Show histograms from ROOT file and THttpServer' },
470+
{ name: 'Superimpose', url: `${demopath}httpserver.C/?file=${filepath}hsimple.root&item=[job1/Files/job1.root/hpx,hsimple.root/hpx;1]&opt=logy`, title: 'Superimpose objects from ROOT file and online server' }
467471
],
468472
'httpcontrol.C' : [
469473
{ link: 'https://github.com/root-project/root/blob/master/tutorials/http/httpcontrol.C' },
470-
{ name: 'Default page', url: 'httpcontrol.C/', title: 'Default HTML page of running httpscontrol.C macro (snapshot)' },
471-
{ name: 'Text output', url: 'httpcontrol.C/?layout=simple&item=Debug&monitoring=0', title: 'Custom text output, using MathJax.js; also disable default monitoring' },
472-
{ name: 'Text output (2)', url: 'httpcontrol.C/Debug/draw.htm', title: 'Custom text output without browser' }
474+
{ name: 'Default page', url: demopath + 'httpcontrol.C/', title: 'Default HTML page of running httpscontrol.C macro (snapshot)' },
475+
{ name: 'Text output', url: demopath + 'httpcontrol.C/?layout=simple&item=Debug&monitoring=0', title: 'Custom text output, using MathJax.js; also disable default monitoring' },
476+
{ name: 'Text output (2)', url: demopath + 'httpcontrol.C/Debug/draw.htm', title: 'Custom text output without browser' }
473477
],
474478
'Go4ExampleSimple' : [
475479
{ link: 'https://github.com/linev/go4/tree/master/Go4ExampleSimple' },
476-
{ name: 'Main page', url: 'Go4ExampleSimple/', title: 'Main page of running Go4ExampleSimple example (snapshot)' },
477-
{ name: 'Without status line', url: 'Go4ExampleSimple/?nostatus', title: 'Suppress output of status line' },
478-
{ name: 'Draw condition', url: 'Go4ExampleSimple/?nostatus&item=Conditions/cHis1', title: 'Show TGo4Condition values correspondent histogram' },
479-
{ name: 'Edit condition', url: 'Go4ExampleSimple/?item=Conditions/cHis1&opt=editor', title: 'Editing condition values' },
480-
{ name: 'Edit parameter', url: 'Go4ExampleSimple/?item=Parameters/Par1&opt=editor', title: 'Editing parameter values' },
481-
{ name: 'Debug output', url: 'Go4ExampleSimple/?item=Status/Log', title: 'Show analysis log output' },
482-
{ name: 'Draw picture', url: 'Go4ExampleSimple/?nostatus&item=Pictures/condSet', title: 'Show TGo4Picture, which fetch and draw many other objects' },
483-
{ name: 'Processing rate', url: 'Go4ExampleSimple/?item=Status/EventsRate', title: 'Show analysis events processing rate as TGraph' },
484-
{ name: 'Analysis configuration', url: 'Go4ExampleSimple/?item=Control/Analysis', title: 'Change analysis configurations' },
485-
{ name: 'Terminal', url: 'Go4ExampleSimple/?item=Control/Terminal', title: 'Analysis terminal output plus several control elements' }
480+
{ name: 'Main page', url: demopath + 'Go4ExampleSimple/', title: 'Main page of running Go4ExampleSimple example (snapshot)' },
481+
{ name: 'Without status line', url: demopath + 'Go4ExampleSimple/?nostatus', title: 'Suppress output of status line' },
482+
{ name: 'Draw condition', url: demopath + 'Go4ExampleSimple/?nostatus&item=Conditions/cHis1', title: 'Show TGo4Condition values correspondent histogram' },
483+
{ name: 'Edit condition', url: demopath + 'Go4ExampleSimple/?item=Conditions/cHis1&opt=editor', title: 'Editing condition values' },
484+
{ name: 'Edit parameter', url: demopath + 'Go4ExampleSimple/?item=Parameters/Par1&opt=editor', title: 'Editing parameter values' },
485+
{ name: 'Debug output', url: demopath + 'Go4ExampleSimple/?item=Status/Log', title: 'Show analysis log output' },
486+
{ name: 'Draw picture', url: demopath + 'Go4ExampleSimple/?nostatus&item=Pictures/condSet', title: 'Show TGo4Picture, which fetch and draw many other objects' },
487+
{ name: 'Processing rate', url: demopath + 'Go4ExampleSimple/?item=Status/EventsRate', title: 'Show analysis events processing rate as TGraph' },
488+
{ name: 'Analysis configuration', url: demopath + 'Go4ExampleSimple/?item=Control/Analysis', title: 'Change analysis configurations' },
489+
{ name: 'Terminal', url: demopath + 'Go4ExampleSimple/?item=Control/Terminal', title: 'Analysis terminal output plus several control elements' }
486490
]
487491
};
488492

demo/multigraph.htm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@
3535
const graph1 = createTGraph(npoints, xpts, ypts);
3636
graph1.fLineColor = 2;
3737
graph1.fMarkerSize = 2;
38-
xpts = [];
39-
ypts = [];
38+
const xpts2 = [], ypts2 = [];
4039
for (let i = 0; i < npoints; i++) {
4140
if (cnt%2 === 1) {
42-
xpts.push(i);
43-
ypts.push(i*i);
41+
xpts2.push(i);
42+
ypts2.push(i*i);
4443
} else {
45-
xpts.push(i);
46-
ypts.push(Math.sqrt(i));
44+
xpts2.push(i);
45+
ypts2.push(Math.sqrt(i));
4746
}
4847
}
49-
const graph2 = createTGraph(npoints, xpts, ypts);
48+
const graph2 = createTGraph(npoints, xpts2, ypts2);
5049
graph2.fLineColor = 3;
5150
graph2.fMarkerSize = 2;
5251

demo/update_draw.htm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@
2626
<script type='module'>
2727
import { httpRequest, redraw, decodeUrl, registerForResize, GridDisplay } from 'jsroot';
2828

29-
let mdi = null, cnt = 0, drawopt = null, addr = null;
29+
let mdi = null, cnt = 0, drawopt = null, addr = null, path = 'https://root.cern/js/latest/demo/';
30+
31+
if ((window.location.host.indexOf('root.cern') >= 0) || (window.location.host.indexOf('jsroot.gsi.de') >= 0))
32+
path = '';
3033

3134
function updateGUI() {
3235

3336
// here set of generated json files are used
34-
// One could specify addres of running THttpServer like http://localhost:8080/Canvases/c1/root.json.gz?compact=23
37+
// One could specify address of running THttpServer like http://localhost:8080/Canvases/c1/root.json.gz?compact=23
3538
// Or one can create root.json file in the application and place it on the webserver
3639
// To run demo, one should generate rootXX.json files using demo.C macro
3740

3841
let request_addr = addr || `root${cnt % 20}.json`,
3942
request_count = cnt++;
4043

41-
httpRequest(request_addr, 'object').then(histo => {
44+
httpRequest(path + request_addr, 'object').then(histo => {
4245
// when use grid layout, use counter value stored in request itself
4346
let frame = mdi ? mdi.findFrame(`item${request_count % mdi.numGridFrames()}`, true) : 'drawing';
4447

demo/without_id.htm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
<script type='module'>
1717
import { httpRequest, draw } from 'jsroot';
1818

19-
const obj = await httpRequest('hpx.json', 'object');
19+
let path = 'https://root.cern/js/latest/demo/';
20+
21+
if ((window.location.host.indexOf('root.cern') >= 0) || (window.location.host.indexOf('jsroot.gsi.de') >= 0))
22+
path = '';
23+
24+
const obj = await httpRequest(path + 'hpx.json', 'object');
2025

2126
// here demonstrated that div can be used without id attribute
2227
draw(document.getElementsByTagName('div')[0], obj, 'hist');

0 commit comments

Comments
 (0)