Skip to content

Commit 6d96a61

Browse files
committed
Update docu
1 parent 1071149 commit 6d96a61

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

docs/JSROOT.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,18 @@ Following draw options could be specified (separated by semicolon or ';'):
111111
- rotate - enable automatic rotation of the geometry
112112

113113

114-
It is typical, that not all geometry volumes should be displayed.
115-
In simple case one just display only subvolume (with all its daughters) like:
114+
It is possible to dispplay only part of geometry model. For instance, one could select sub-item like:
116115

117116
<http://jsroot.gsi.de/dev/?file=../files/geom/rootgeom.root&item=simple1;1/Nodes/REPLICA_1>
118117

119118
Or one can use simple selection syntax (work only with first-level volumes):
120119

121120
<http://jsroot.gsi.de/dev/?file=../files/geom/rootgeom.root&item=simple1;1&opt=-bar1-bar2>
122121

123-
Syntax uses '+' sign to show specified volume and '-' sign to hide specified volume.
124-
One could use wildcard sign like '+TUBE1*'.
122+
Syntax uses '+' sign to enable visibility flag of specified volume and '-' sign to disable visibility.
123+
One could use wildcard symbol like '+TUBE1*'.
125124

126-
Or one could reuse ROOT macro, which normally invoked when display geometry in ROOT itself.
125+
Another way to configure visibility flags is usage of ROOT macros, used to display geometry in ROOT itself.
127126
Example of such macro can be found in root tutorials. Typically it looks like:
128127

129128
{
@@ -255,8 +254,7 @@ If one has a web server which already provides such JSON file, one could specify
255254

256255
<https://root.cern.ch/js/latest/demo/demo.htm?addr=../httpserver.C/Canvases/c1/root.json.gz>
257256

258-
Here the same problem with [Cross-Origin Request](https://developer.mozilla.org/en/http_access_control) can appear.
259-
If the web server configuration cannot be changed, just copy JSROOT to the web server itself.
257+
Here the same problem with [Cross-Origin Request](https://developer.mozilla.org/en/http_access_control) can appear. If the web server configuration cannot be changed, just copy JSROOT to the web server itself.
260258

261259

262260
### Binary file-based monitoring (not recommended)
@@ -291,18 +289,16 @@ Details about the JSROOT API can be found in the next chapters.
291289

292290
## JSROOT API
293291

294-
JSROOT consists of several libraries (.js files). They are all provided in the ROOT
295-
repository and are available in the 'etc/http/scripts/' subfolder.
292+
JSROOT can be downloaded from <https://github.com/linev/jsroot>.
293+
It also provided with each ROOT distribution in `etc/http/scripts/` subfolder.
296294

297-
Only the central classes and functions will be documented here.
298-
299-
Many different examples of JSROOT API usage can be found on [JSROOT API](https://root.cern.ch/js/latest/api.htm) page
295+
Many different examples of JSROOT API usage can be found on [JSROOT API examples](https://root.cern.ch/js/latest/api.htm) page.
300296

301297

302298
### Scripts loading
303299

304300
Before JSROOT can be used, all appropriate scripts should be loaded.
305-
Any HTML pages where JSROOT is used should include the JSRootCore.js script.
301+
HTML pages where JSROOT is used should include the JSRootCore.js script.
306302
The `<head>` section of the HTML page should have the following line:
307303

308304
<script type="text/javascript" src="https://root.cern.ch/js/latest/scripts/JSRootCore.js?2d"></script>
@@ -311,7 +307,7 @@ Here, the default location of JSROOT is specified. One could have a local copy o
311307

312308
<script type="text/javascript" src="http://your_root_server:8080/jsrootsys/scripts/JSRootCore.js?2d"></script>
313309

314-
In URL string with JSRootCore.js script one should specify which JSROOT functionality will be loaded:
310+
In URL string with JSRootCore.js script one can specify which JSROOT functionality should be loaded:
315311

316312
+ '2d' normal drawing for objects like TH1/TCanvas/TGraph
317313
+ 'more2d' more classes for 2D drawing like TH2/TF1/TEllipse
@@ -334,11 +330,15 @@ One could use minified version of all scripts (as shown in example) - this reduc
334330
### Use of JSON
335331

336332
It is strongly recommended to use JSON when communicating with ROOT application.
337-
THttpServer provides a JSON representation for every registered object with an url address like:
333+
THttpServer provides a JSON representation for every registered object with an url address like:
338334

339335
http://your_root_server:8080/Canvases/c1/root.json
340336

341-
Such JSON representation generated using the [TBufferJSON](http://root.cern.ch/root/html/TBufferJSON.html) class.
337+
Such JSON representation generated using the [TBufferJSON](http://root.cern.ch/root/html/TBufferJSON.html) class. One could create JSON file for any ROOT object directly, just writing in the code:
338+
339+
...
340+
obj->SaveAs("file.json");
341+
...
342342

343343
To access data from a remote web server, it is recommended to use the [XMLHttpRequest](http://en.wikipedia.org/wiki/XMLHttpRequest) class.
344344
JSROOT provides a special method to create such class and properly handle it in different browsers.
@@ -347,12 +347,12 @@ For receiving JSON from a server one could use following code:
347347
var req = JSROOT.NewHttpRequest("http://your_root_server:8080/Canvases/c1/root.json", 'object', userCallback);
348348
req.send(null);
349349

350-
In the callback function, one gets JavaScript object (or null in case of failure)
350+
In the callback function one gets JavaScript object (or null in case of failure)
351351

352352

353353
### Objects drawing
354354

355-
After an object has been created, one can directly draw it. If somewhere in a HTML page there is a `<div>` element:
355+
After an object has been created, one can directly draw it. If HTML page has `<div>` element:
356356

357357
...
358358
<div id="drawing"></div>
@@ -383,8 +383,6 @@ To correctly cleanup JSROOT drawings from HTML element, one should call:
383383

384384
JSROOT.cleanup("drawing");
385385

386-
Many examples of supported ROOT classes and draw options can be found on [JSROOT examples](https://root.cern.ch/js/latest/examples.htm) page.
387-
388386

389387
### File API
390388

@@ -399,7 +397,12 @@ For example, reading an object from a file and displaying it will look like:
399397
JSROOT.draw("drawing", obj, "colz");
400398
});
401399
});
400+
401+
Similar example with JSON file:
402402

403-
403+
var filename = "http://jsroot.gsi.de/files/th2ul.json.gz";
404+
JSROOT.NewHttpRequest(filename, 'object', function(obj) {
405+
JSROOT.draw("drawing", obj, "lego");
406+
}).send(null);
404407

405408

0 commit comments

Comments
 (0)