Skip to content

Commit f28d0ae

Browse files
committed
Add more examples
1 parent d885849 commit f28d0ae

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

modules/core.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let version_id = '7.4.0';
55

66
/** @summary version date
77
* @desc Release date in format day/month/year like '14/04/2022' */
8-
let version_date = '14/06/2023';
8+
let version_date = '15/06/2023';
99

1010
/** @summary version id and date
1111
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -736,7 +736,13 @@ function parseMulti(json) {
736736
* Or one can again parse json with {@link parse} function
737737
* @param {object} obj - JavaScript object to convert
738738
* @param {number} [spacing] - optional line spacing in JSON
739-
* @return {string} produced JSON code */
739+
* @return {string} produced JSON code
740+
* @example
741+
* import { openFile, draw, toJSON } from 'https://root.cern/js/latest/modules/main.mjs';
742+
* let file = await openFile('https://root.cern/js/files/hsimple.root');
743+
* let obj = await file.readObject('hpxpy;1');
744+
* obj.fTitle = 'New histogram title';
745+
* let json = toJSON(obj); */
740746
function toJSON(obj, spacing) {
741747
if (!isObject(obj)) return '';
742748

modules/draw.mjs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ function getDrawSettings(kind, selector) {
288288
return res;
289289
}
290290

291-
/** @summary Set default draw option for provided class */
291+
/** @summary Set default draw option for provided class
292+
* @example
293+
import { setDefaultDrawOpt } from 'https://root.cern/js/latest/modules/draw.mjs';
294+
setDefaultDrawOpt('TH1', 'text');
295+
setDefaultDrawOpt('TH2', 'col'); */
292296
function setDefaultDrawOpt(classname, opt) {
293297
let handle = getDrawHandle(prROOT + classname, 0);
294298
if (handle)
@@ -422,7 +426,18 @@ async function draw(dom, obj, opt) {
422426
* @return {Promise} with painter object
423427
* @desc If drawing was not done before, it will be performed with {@link draw}.
424428
* Otherwise drawing content will be updated
425-
* @public */
429+
* @public
430+
* @example
431+
* import { openFile } from 'https://root.cern/js/latest/modules/io.mjs';
432+
* import { draw, redraw } from 'https://root.cern/js/latest/modules/draw.mjs';
433+
* let file = await openFile('https://root.cern/js/files/hsimple.root');
434+
* let obj = await file.readObject('hpxpy;1');
435+
* await draw('drawing', obj, 'colz');
436+
* let cnt = 0;
437+
* setInterval(() => {
438+
* obj.fTitle = `Next iteration ${cnt++}`;
439+
* redraw('drawing', obj, 'colz');
440+
* }, 1000); */
426441
async function redraw(dom, obj, opt) {
427442

428443
if (!isObject(obj))
@@ -531,8 +546,8 @@ function addStreamerInfosForPainter(lst) {
531546
* import { openFile, makeImage } from 'jsroot';
532547
* let file = await openFile('https://root.cern/js/files/hsimple.root');
533548
* let object = await file.readObject('hpxpy;1');
534-
* let png64 = await makeImage({ format: 'png', object, option: 'lego2,pal67', width: 1200, height: 800 });
535-
* let pngbuf = await makeImage({ format: 'png', as_buffer: true, object, option: 'lego2,pal67', width: 1200, height: 800 }); */
549+
* let png64 = await makeImage({ format: 'png', object, option: 'colz', width: 1200, height: 800 });
550+
* let pngbuf = await makeImage({ format: 'png', as_buffer: true, object, option: 'colz', width: 1200, height: 800 }); */
536551
async function makeImage(args) {
537552
if (!args) args = {};
538553

0 commit comments

Comments
 (0)