Global

Members

(private, constant) AxisPainterMethods

Base axis painter methods

Source:

(private, constant) Box3D

Help structures for calculating Box mesh

Source:

(private, constant) CustomStreamers

Custom streamers for root classes

Description:
  • map of user-streamer function like func(buf,obj) or alias (classname) which can be used to read that function or list of read functions

Source:

map of user-streamer function like func(buf,obj) or alias (classname) which can be used to read that function or list of read functions

(private, constant) DirectStreamers

these are streamers which do not handle version regularly

Description:
  • used for special classes like TRef or TBasket

Source:

used for special classes like TRef or TBasket

(private, constant) FrameInteractive

Set of frame interactivity methods

Source:

(constant) HEX_CHARS

js-sha256

.

Description:
Source:
Version:
  • 0.10.1
Author:
  • <p>Chen, Yi-Cyuan [emn178@gmail.com]</p>
License:
  • MIT

(constant) __4294967296

© 2016 Nathan Rugg nmrugg@gmail.com Code extracted from https://github.com/LZMA-JS/LZMA-JS

.

Description:
  • © 2016 Nathan Rugg nmrugg@gmail.com Code extracted from https://github.com/LZMA-JS/LZMA-JS

Source:

© 2016 Nathan Rugg nmrugg@gmail.com Code extracted from https://github.com/LZMA-JS/LZMA-JS

(private, constant) atob_func

atob function in all environments

Source:

(private) batch_mode

Is batch mode flag

Source:

(private, constant) browser

browser detection flags

Source:

(private, constant) btoa_func

btoa function in all environments

Source:

(private, constant) drawFuncs

list of registered draw functions

Source:

(private) first_hpainter

Current hierarchy painter

Description:
Source:

Instance of HierarchyPainter object

(private) gbl_colors_list

list of global root colors

Source:

(private, constant) geoBITS

TGeo-related bits

Source:

(private, constant) internals

internal data

Source:

(private, constant) latex_features

array defines features supported by latex parser, used by both old and new parsers

Source:

(private, constant) methodsCache

variable used to keep methods for known classes

Source:

(private, constant) nodejs

Is node.js flag

Source:

(private) source_dir

Location of JSROOT modules

Description:
  • Automatically detected and used to dynamically load other modules

Source:

Automatically detected and used to dynamically load other modules

(private, constant) symbolsRegexCache

Create a single regex to detect any symbol to replace, apply longer symbols first

Source:

(constant) version

version id and date

Description:
Source:

Produced by concatenation of version_id and version_date Like '7.0.0 14/04/2022'

(constant) version_date

version date

Description:
  • Release date in format day/month/year like '14/04/2022'

Source:

Release date in format day/month/year like '14/04/2022'

(constant) version_id

version id

Description:
  • For the JSROOT release the string in format 'major.minor.patch' like '7.0.0'

Source:

For the JSROOT release the string in format 'major.minor.patch' like '7.0.0'

Methods

(private) BIT(n) → {Number}

Generate mask for given bit

Source:
Parameters:
Name Type Description
n number

bit number

Returns:

produced mask

Type
Number

(private) HMAC()

HMAC implementation

Description:
  • see https://en.wikipedia.org/wiki/HMAC for more details

Source:

(private) LZ4_uncompress(input, output) → {Number}

Decode a block.

Description:
  • Decode a block. Assumptions: input contains all sequences of a chunk, output is large enough to receive the decoded data. If the output buffer is too small, an error will be thrown. If the returned value is negative, an error occured at the returned offset.

Source:
Parameters:
Name Type Description
input Buffer

input data

output Buffer

output data

Returns:

number of decoded bytes

Type
Number

(async, private) R__unzip() → {Promise}

Reads header envelope, determines zipped size and unzip content

Source:
Returns:

with unzipped content

Type
Promise

(async, private) _ensureJSROOT()

Ensure global JSROOT and v6 support methods

Source:

(private) _getTF1Save()

Get interpolation in saved buffer

Description:
  • Several checks must be done before function can be used

Source:

(async, private) _loadJSDOM() → {Promise}

Load and initialize JSDOM from nodes

Source:
Returns:

with d3 selection for d3_body

Type
Promise

(private) add3DMesh()

Add 3D mesh to frame painter

Source:

(private) addClassMethods()

Let directly assign methods when doing I/O

Source:

(private) addColor(rgb, lstopt) → {number}

Add new color

Source:
Parameters:
Name Type Attributes Description
rgb string

color name or just string with rgb value

lst array <optional>

optional colors list, to which add colors

Returns:

index of new color

Type
number

(private) addCustomFont()

Register custom font

Source:

(private) addDragHandler()

Add drag for interactive rectangular elements for painter

Source:

(protected) addDrawFunc(args)

Register draw function for the class

Description:
  • List of supported draw options could be provided, separated with ';'

Source:
Parameters:
Name Type Description
args object

arguments

Properties
Name Type Attributes Description
name string | regexp

class name or regexp pattern

func function <optional>

draw function

draw function <optional>

async function to load draw function

class function <optional>

async function to load painter class with static draw function

direct boolean <optional>

if true, function is just Redraw() method of ObjectPainter

opt string <optional>

list of supported draw options (separated with semicolon) like 'col;scat;'

icon string <optional>

icon name shown for the class in hierarchy browser

draw_field string <optional>

draw only data member from object, like fHistogram

(private) addHighlightStyle()

Configure special style used for highlight or dragging elements

Source:

(private) addMethods(obj, typenameopt)

Adds specific methods to the object.

Description:
  • JSROOT implements some basic methods for different ROOT classes.

Source:
Parameters:
Name Type Attributes Description
obj object

object where methods are assigned

typename string <optional>

optional typename, if not specified, obj._typename will be used

(private) addMoveHandler()

Add move handlers for drawn element

Source:

(private) addStreamerInfosForPainter()

Scan streamer infos for derived classes

Description:
  • Assign draw functions for such derived classes

Source:

addUserStreamer()

Add custom streamer

Source:

(private) adoptRootColors()

Either TObjArray of TColor instances or just plain array with rgb() code.

Description:
  • Either TObjArray of TColor instances or just plain array with rgb() code. List of colors typically stored together with TCanvas primitives

Source:

(private) afterRender3D()

Post-process result of rendering

Description:
  • used together with SVG or node.js image rendering

Source:

(private) applyAttributesToMathJax()

Apply attributes to mathjax drawing

Source:

(private) approximateLabelWidth()

Source:

(private) assign3DHandler()

Assigns method to handle 3D drawings inside SVG

Source:

(private) assignContextMenu()

Assign handler for context menu for painter draw element

Source:

(private) assignFrame3DMethods()

Assign 3D methods for frame painter

Source:

(private) assignRAxisMethods()

assign methods for the RAxis objects

Source:

(private) before3DDraw()

Prepare frame painter for 3D drawing

Source:

(private) beforeRender3D()

Cleanup previous renderings before doing next one

Description:
  • used together with SVG

Source:

binl2rstr(input) → {string}

Convert an array of little-endian words to a string

.

Description:
  • Convert an array of little-endian words to a string

Source:
Parameters:
Name Type Description
input Array.<number>

MD5 Array

Returns:

MD5 string

Type
string

(private) binlMD5(x, len) → {Array.<number>}

Calculate the MD5 of an array of little-endian words, and a bit length.

Description:
  • Calculate the MD5 of an array of little-endian words, and a bit length.

Source:
Parameters:
Name Type Description
x Array

Array of little-endian words

len number

Bit length

Returns:

MD5 Array

Type
Array.<number>

(private) bitRotateLeft()

Source:

(private) browserIconClick()

handle click on browser icon

Source:

build(obj, optopt) → {object}

Build three.js model for given geometry object

Source:
Example
import { build } from 'https://root.cern/js/latest/modules/geom/TGeoPainter.mjs';
let obj3d = build(obj);
// this is three.js object and can be now inserted in the scene
Parameters:
Name Type Attributes Description
obj Object

TGeo-related object

opt Object <optional>

options

Properties
Name Type Attributes Default Description
vislevel Number <optional>

visibility level like TGeoManager, when not specified - show all

numnodes Number <optional>
1000

maximal number of visible nodes

numfaces Number <optional>
100000

approx maximal number of created triangles

instancing Number <optional>
-1

<0 disable use of InstancedMesh, =0 only for large geometries, >0 enforce usage of InstancedMesh

doubleside boolean <optional>
false

use double-side material

wireframe boolean <optional>
false

show wireframe for created shapes

transparency boolean <optional>
0

make nodes transparent

dflt_colors boolean <optional>
false

use default ROOT colors

set_names boolean <optional>
true

set names to all Object3D instances

set_origin boolean <optional>
false

set TGeoNode/TGeoVolume as Object3D.userData

Returns:

Object3D with created model

Type
object

(private) buildCompositeVolume()

Function used to build hierarchy of elements of composite shapes

Source:

(async) buildGUI(gui_element, gui_kind) → {Promise}

Build main GUI

Description:
  • Used in many HTML files to create JSROOT GUI elements

Source:
Example
import { buildGUI } from 'https://root.cern/js/latest/modules/gui.mjs';
buildGUI('guiDiv');
Parameters:
Name Type Description
gui_element String

id of the <div> element

gui_kind String

either 'online', 'nobrowser', 'draw'

Returns:

with HierarchyPainter instance

Type
Promise

(private) buildHist2dContour()

Build histogram contour lines

Source:

(private) buildOverlapVolume()

Function used to build hierarchy of elements of overlap object

Source:

(private) buildSurf3D()

Build 3d surface

Description:
  • Make it indepependent from three.js to be able reuse it for 2d case

Source:

(private) buildSvgCurve()

Build smooth SVG curve uzing Bezier

Description:
  • Reuse code from https://stackoverflow.com/questions/62855310

Source:

(private) canDrawHandle()

Returns true if handle can be potentially drawn

Source:

(private) canExpandHandle()

Check if draw handle for specified object can do expand

Source:

(private) change3DCamera()

Change camera kind in frame painter

Source:

(private) checkArrayPrototype()

Checks array kind

Description:
  • return 0 when not array 1 - when arbitrary array 2 - when plain (1-dim) array with same-type content

Source:

(private) checkDuplicates()

Check duplicates

Source:

(private) chooseTimeFormat()

Tries to choose time format for provided time interval

Source:

cleanup(dom)

Safely remove all drawings from specified element

Source:
Example
import { cleanup } from 'https://root.cern/js/latest/modules/base/ObjectPainter.mjs';
cleanup('drawing');
cleanup(document.querySelector('#drawing'));
Parameters:
Name Type Description
dom string | object

id or DOM element

(private) cleanupRender3D()

Cleanup created renderer object

Source:

(private) cleanupShape()

Cleanup shape entity

Source:

(private) clone() → {object}

Make deep clone of the object, including all sub-objects

Source:
Returns:

cloned object

Type
object

(private) closeCurrentWindow()

Tries to close current browser tab

Description:
  • Many browsers do not allow simple window.close() call, therefore try several workarounds

Source:

closeMenu(menunameopt)

Close previousely created and shown JSROOT menu

Source:
Parameters:
Name Type Attributes Description
menuname string <optional>

optional menu name

(private) compare_stacks() → {Number}

Compares two stacks.

Source:
Returns:

0 if same, -1 when stack1 < stack2, +1 when stack1 > stack2

Type
Number

(private) compressSVG()

Compress SVG code, produced from drawing

Description:
  • removes extra info or empty elements

Source:

(async) connectWebWindow(arg) → {Promise}

Method used to initialize connection to web window.

Source:
Parameters:
Name Type Description
arg object

arguments

Properties
Name Type Attributes Default Description
socket_kind string <optional>

kind of connection longpoll|websocket, detected automatically from URL

credits number <optional>
10

number of packets which can be send to server without acknowledge

receiver object

instance of receiver for websocket events, allows to initiate connection immediately

first_recv string <optional>

required prefix in the first message from RWebWindow, remain part of message will be returned in handle.first_msg

href string <optional>

URL to RWebWindow, using window.location.href by default

Returns:

for ready-to-use WebWindowHandle instance

Type
Promise

(private) convert3DtoPadNDC()

Converts 3D coordiante to the pad NDC

Source:

convertDate()

Convert Date object into string used preconfigured time zone

Description:
  • Time zone stored in settings.TimeZone

Source:

(private) countGeometryFaces(geom)

Returns number of faces for provided geometry

Source:
Parameters:
Name Type Description
geom

can be BufferGeometry, CsgGeometry or interim array of polygons

(private) countNumShapes()

Returns number of shapes

Description:
  • Used to count total shapes number in composites

Source:

create(typename)

Create some ROOT classes

Description:
  • Supported classes: TObject, TNamed, TList, TAxis, TLine, TText, TLatex, TPad, TCanvas

Source:
Example
import { create } from 'https://root.cern/js/latest/modules/core.mjs';
let obj = create('TNamed');
obj.fName = 'name';
obj.fTitle = 'title';
Parameters:
Name Type Description
typename string

ROOT class name

(private) create3DLineMaterial()

Create material for 3D line

Description:
  • Takes into account dashed properties

Source:

(private) create3DScene() → {Promise}

Create all necessary components for 3D drawings in frame painter

Source:
Returns:

when render3d !== -1

Type
Promise

(private) create8edgesBuffer()

Creates 8 edges geometry

Source:

(private) createArb8Buffer()

Creates arb8 geometrey

Source:

(private) createComposite()

Creates geometrey for composite shape

Source:

(private) createCubeBuffer()

Creates cube geometrey

Source:

(private) createEltuBuffer()

Creates eltu geometrey

Source:

(private) createFlippedMesh(shape, material)

Create flipped mesh for the shape

Description:
  • When transformation matrix includes one or several inversion of axis, one should inverse geometry object, otherwise three.js cannot correctly draw it

Source:
Parameters:
Name Type Description
shape Object

TGeoShape object

material Object

material

(private) createFrustum()

Creates frustum

Source:

(private) createGeoPainter()

Create geo painter

Source:

(private) createGeometry(shape, limit)

Creates geometry model for the provided shape

Description:
    • if limit === 0 (or undefined) returns BufferGeometry
    • if limit < 0 just returns estimated number of faces
    • if limit > 0 return list of CsgPolygons (used only for composite shapes)
Source:
Parameters:
Name Type Description
shape Object

instance of TGeoShape object

limit Number

defines return value, see details

(private) createHalfSpace()

Creates half-space geometry for given shape

Description:
  • Just big-enough triangle to make BSP calculations

Source:

createHistogram(typename, nbinsx, nbinsyopt, nbinszopt) → {Object}

Create histogram object of specified type

Source:
Example
import { createHistogram } from 'https://root.cern/js/latest/modules/core.mjs';
let h1 = createHistogram('TH1I', 20);
h1.fName = 'Hist1';
h1.fTitle = 'Histogram title';
h1.fXaxis.fTitle = 'xaxis';
h1.fYaxis.fTitle = 'yaxis';
h1.fXaxis.fLabelSize = 0.02;
Parameters:
Name Type Attributes Description
typename string

histogram typename like 'TH1I' or 'TH2F'

nbinsx number

number of bins on X-axis

nbinsy number <optional>

number of bins on Y-axis (for 2D/3D histograms)

nbinsz number <optional>

number of bins on Z-axis (for 3D histograms)

Returns:

created histogram object

Type
Object

(private) createHttpRequest()

Method to create http request, without promise can be used only in browser environment

Source:

(private) createHypeBuffer()

Creates hype geometrey

Source:

(private) createInspectorContent()

Create hierarchy for object inspector

Source:

(private) createItem()

create hierarchy item for geo object

Source:

(private) createLineSegments()

Create LineSegments mesh (or only geometry)

Description:
  • If required, calculates lineDistance attribute for dashed geometries

Source:

(private) createList()

create list entity for geo object

Source:

(private) createMaterial()

Create node material

Source:

(private) createMatrix()

Creates Matrix4 from TGeoMatrix

Source:

(private) createMemberStreamer()

create member entry for streamer element

Description:
  • used for reading of data

Source:

createMenu(evntopt, handleropt, menunameopt)

Create JSROOT menu

Description:
Source:
Example
import { createMenu } from 'https://root.cern/js/latest/modules/gui/menu.mjs';
let menu = await createMenu());
menu.add('First', () => console.log('Click first'));
let flag = true;
menu.addchk(flag, 'Checked', arg => console.log(`Now flag is ${arg}`));
menu.show();
Parameters:
Name Type Attributes Description
evnt object <optional>

event object like mouse context menu event

handler object <optional>

object with handling function, in this case one not need to bind function

menuname string <optional>

optional menu name

(private) createNormal()

create geometry to make cut on specified axis

Source:

(private) createOrbitControl()

Create OrbitControls for painter

Source:

(private) createParaBuffer()

Creates PARA geometrey

Source:

(private) createParaboloidBuffer()

Creates para geometrey

Source:

(private) createPolygonBuffer()

Creates polygon geometrey

Source:

(private) createProjectionMatrix()

Creates projection matrix for the camera

Source:

(async, private) createRender3D(width, height, render3d, args) → {Promise}

Creates renderer for the 3D drawings

Source:
Parameters:
Name Type Description
width value

rendering width

height value

rendering height

render3d value

render type, see constants.Render3D

args object

different arguments for creating 3D renderer

Returns:

with renderer object

Type
Promise

(private) createRootColors()

Generates all root colors, used also in jstests to reset colors

Source:

(private) createServerGeometry()

Create single shape from provided raw data from web viewer.

Description:
  • If nsegm changed, shape will be recreated

Source:

(private) createSphereBuffer()

Creates sphere geometrey

Source:

(private) createStreamerElement()

create element of the streamer

Source:

(private) createStreamerInfoContent()

Create hierarchy for streamer info object

Source:

createTGraph(npoints, xptsopt, yptsopt)

Creates TGraph object

Source:
Parameters:
Name Type Attributes Description
npoints number

number of points in TGraph

xpts array <optional>

array with X coordinates

ypts array <optional>

array with Y coordinates

createTHStack()

Creates THStack object

Description:
  • As arguments one could specify any number of histograms objects

Source:
Example
import { createHistogram, createTHStack } from 'https://root.cern/js/latest/modules/core.mjs';
let nbinsx = 20;
let h1 = createHistogram('TH1F', nbinsx);
let h2 = createHistogram('TH1F', nbinsx);
let h3 = createHistogram('TH1F', nbinsx);
let stack = createTHStack(h1, h2, h3);

createTMultiGraph()

Creates TMultiGraph object

Description:
  • As arguments one could specify any number of TGraph objects

Source:
Example
import { createTGraph, createTMultiGraph } from 'https://root.cern/js/latest/modules/core.mjs';
let gr1 = createTGraph(100);
let gr2 = createTGraph(100);
let gr3 = createTGraph(100);
let mgr = createTMultiGraph(gr1, gr2, gr3);

createTPolyLine(npoints, use_int32opt)

Creates TPolyLine object

Source:
Parameters:
Name Type Attributes Description
npoints number

number of points

use_int32 boolean <optional>

use Int32Array type for points, default is Float32Array

(private) createTessellatedBuffer()

Creates tessalated geometrey

Source:

(private) createTorusBuffer()

Creates torus geometrey

Source:

(private) createTrapezoidBuffer()

Creates Ttrapezoid geometrey

Source:

(private) createTreePlayer()

Create painter to perform tree drawing on server side

Source:

(private) createTubeBuffer()

Creates tube geometrey

Source:

(private) createWebObjectOptions()

Fill TWebObjectOptions for painter

Source:

(private) createXtruBuffer()

Creates xtru geometrey

Source:

decodeUrl(urlopt) → {Object}

decodes URL options after '?' mark

Description:
  • Following options supported ?opt1&opt2=3

Source:
Example
import { decodeUrl } from 'https://root.cern/js/latest/modules/core.mjs';
let d = decodeUrl('any?opt1&op2=3');
console.log(`Has opt1 ${d.has('opt1')}`);     // true
console.log(`Get opt1 ${d.get('opt1')}`);     // ''
console.log(`Get opt2 ${d.get('opt2')}`);     // '3'
console.log(`Get opt3 ${d.get('opt3','-')}`); // '-'
Parameters:
Name Type Attributes Description
url string <optional>

URL string with options, document.URL will be used when not specified

Returns:

with .has(opt) and .get(opt,dflt) methods

Type
Object

(private) decodeWebCanvasColors()

Decode list of ROOT colors coded by TWebCanvas

Source:

decompress()

decompress ROOT LZMA buffer

Description:
  • ROOT buffer has internal header of 29 bytes long which can be simply ignored

Source:

(private) defineMemberTypeName()

return type name of given member in the class

Source:

(private) detectBranchMemberClass()

try to define classname for the branch member, scanning list of branches

Source:

(private) detectFont()

Try to detect and create font handler for SVG text node

Source:

(private) detectRightButton()

Detect mouse right button

Source:

(private) directDrawTFrame()

direct draw of TFrame object,

Description:
  • pad or canvas should already exist

Source:

(private) disposeThreejsObject()

Method cleanup three.js object as much as possible.

Description:
  • Simplify JS engine to remove it from memory

Source:

(async) draw(dom, obj, opt) → {Promise}

Draw object in specified HTML element with given draw options.

Description:
  • An extensive list of support draw options can be found on examples page

Source:
Example
import { openFile } from 'https://root.cern/js/latest/modules/io.mjs';
import { draw } from 'https://root.cern/js/latest/modules/draw.mjs';
let file = await openFile('https://root.cern/js/files/hsimple.root');
let obj = await file.readObject('hpxpy;1');
await draw('drawing', obj, 'colz;logx;gridx;gridy');
Parameters:
Name Type Description
dom string | object

id of div element to draw or directly DOMElement

obj object

object to draw, object type should be registered before with addDrawFunc

opt string

draw options separated by space, comma or semicolon

Returns:

with painter object

Type
Promise

(private) drawAxis3D()

Direct draw function for TAxis3D

Source:

(private) drawBinsContour3D()

Draw TH2 as 3D contour plot

Source:

(private) drawBinsError3D()

Draw TH2 histogram in error mode

Source:

(private) drawBinsLego()

Draw histograms in 3D mode

Source:

(private) drawBinsSurf3D()

Draw TH2 histograms in surf mode

Source:

(private) drawBox()

Draw TBox

Source:

(private) drawBox()

draw RBox object

Source:

(async, private) drawDummy3DGeom()

Draw dummy geometry

Source:

(private) drawEllipse()

Draw TEllipse

Source:

(private) drawHistDisplayItem()

draw RHistDisplayItem object

Source:

(async, private) drawInspector()

Display inspector

Source:

(private) drawJSImage()

Draw JS image

Source:

(private) drawLeafPlayer()

function used with THttpServer when tree is not yet loaded

Source:

(private) drawLine()

draw RLine object

Source:

(async, private) drawList()

draw list content

Description:
  • used to draw all items from TList or TObjArray inserted into the TCanvas list of primitives

Source:

(private) drawMarker()

Draw TMarker

Source:

(private) drawMarker()

draw RMarker object

Source:

(private) drawPie()

Draw TPie

Source:

(private) drawPolyLine()

Draw TPolyLine

Source:

(async, private) drawPolyLine3D()

Direct draw function for TPolyLine3D object

Description:
  • Takes into account dashed properties

Source:

(private) drawPolyMarker()

Draw TPolyMarker

Source:

(async, private) drawPolyMarker3D()

direct draw function for TPolyMarker3D object

Source:

(async, private) drawPolyMarker3D()

direct draw function for TPolyMarker3D object (optionally with geo painter)

Source:

(private) drawRAxis()

draw RAxis object

Source:

(private) drawRFont()

draw RFont object

Source:

(private) drawRFrame()

draw RFrame object

Source:

(private) drawRFrameTitle()

Function used for direct draw of RFrameTitle

Source:

(private) drawRPadSnapshot()

draw RPadSnapshot object

Source:

(private) drawRawText()

Generic text drawing

Source:

(async, private) drawRooPlot()

Draw TRooPlot

Source:

(async, private) drawStreamerInfo()

Display streamer info

Source:

(async, private) drawTFrame()

draw TFrame object

Source:

(private) drawTH2PolyLego()

Draw TH2Poly histogram as lego

Source:

(async, private) drawTPadSnapshot()

draw TPad snapshot from TWebCanvas

Source:

(async, private) drawText()

Draw TText

Source:

(private) drawText()

draw RText object

Source:

(async, private) drawTree()

function called from draw()

Description:
  • just envelope for real TTree::Draw method which do the main job Can be also used for the branch and leaf object

Source:

(async, private) drawTreeDrawResult()

Draw result of tree drawing

Source:

(private) drawTreePlayer()

function used with THttpServer to assign player for the TTree object

Source:

(private) drawTreePlayerKey()

function used with THttpServer when tree is not yet loaded

Source:

(private) drawXYZ()

Draw axes in 3D mode

Source:

drawingJSON(dom) → {string}

Save object, drawn in specified element, as JSON.

Description:
  • Normally it is TCanvas object with list of primitives

Source:
Parameters:
Name Type Description
dom string | object

id of top div element or directly DOMElement

Returns:

produced JSON string

Type
string

(async, private) ensureRCanvas(painter, frame_kind) → {Promise}

Ensure RCanvas and RFrame for the painter object

Description:
  • Assigns DOM, creates and draw RCanvas and RFrame if necessary, add painter to pad list of painters

Source:
Parameters:
Name Type Description
painter Object

painter object to process

frame_kind string | boolean

false for no frame or '3d' for special 3D mode

Returns:

for ready

Type
Promise

(async) ensureTCanvas(painter, frame_kind)

Ensure TCanvas and TFrame for the painter object

Description:
  • Assign dom, creates TCanvas if necessary, add to list of pad painters

Source:
Parameters:
Name Type Description
painter Object

painter object to process

frame_kind string | boolean

false for no frame or '3d' for special 3D mode

(private) expandGeoObject()

Expand geo object

Source:

(private) extendRootColors()

Add new colors from object array

Source:

(private) findBrachStreamerElement()

return TStreamerElement associated with the branch - if any

Description:
  • unfortunately, branch.fID is not number of element in streamer info

Source:

(private) findBranch(name) → {Object}

Search branch with specified name

Source:
Parameters:
Name Type Description
name string

name of the branch

Returns:

found branch

Type
Object

(private) findBranchComplex(name) → {Object}

Special branch search

Description:
  • Name can include extra part, which will be returned in the result

Source:
Parameters:
Name Type Description
name string

name of the branch

Returns:

with 'branch' and 'rest' members

Type
Object

(private) findColor()

Search for specified color in the list of colors

Source:
Returns:

Color index or -1 if fails

(private) findFunction()

Find function with given name

Source:

(private) findItemWithPainter()

find item with 3d painter

Source:

(private) floatToString(value, fmtopt, ret_fmtopt) → {string|Array}

Converts numeric value to string according to specified format.

Source:
Parameters:
Name Type Attributes Default Description
value number

value to convert

fmt string <optional>
'6.4g'

format can be like 5.4g or 4.2e or 6.4f

ret_fmt boolean <optional>

when true returns array with value and actual format like ['0.1','6.4f']

Returns:
  • converted value or array with value and actual format
Type
string | Array

(private) folderHierarchy()

Create hierarchy elements for TFolder object

Source:

(private) geoWarn()

method used to avoid duplication of warnings

Source:

(private) geomBoundingBox()

Returns geometry bounding box

Source:

(private) get3DBox()

Function to extract 3DBox for poly marker and line

Source:

(private) getAbsPosInCanvas()

Calculate absolute position of provided element in canvas

Source:

(private) getActivePad()

Returns current active pad

Description:
  • Should be used only for keyboard handling

Source:

(private) getArrayKind()

Analyze and returns arrays kind

Source:
Returns:

0 if TString (or equivalent), positive value - some basic type, -1 - any other kind

(private) getBinFileContent()

Returns image file content as it should be stored on the disc

Description:
  • Replaces all kind of base64 coding

Source:

(private) getBoundingBox()

extract code of Box3.expandByObject

Description:
  • Major difference - do not traverse hierarchy, support InstancedMesh

Source:

(private) getBranchObjectClass()

return class name of the object, stored in the branch

Source:

(private) getBrowserIcon()

Get icon for the browser

Source:

(private) getColor() → {String}

Return ROOT color by index

Description:
  • Color numbering corresponds typical ROOT colors

Source:
Returns:

with RGB color code or existing color name like 'cyan'

Type
String

(private) getColorExec()

Produce exec string for WebCanas to set color value

Description:
  • Color can be id or string, but should belong to list of known colors For higher color numbers TColor::GetColor(r,g,b) will be invoked to ensure color is exists

Source:

(private) getColorPalette()

Create color palette

Source:

(private) getCustomFont()

Return handle with custom font

Source:

(private) getDocument()

Method returns current document in use

Source:

(private) getDrawHandle()

return draw handle for specified item kind

Description:
  • kind could be ROOT.TH1I for ROOT classes or just kind string like 'Command' or 'Text' selector can be used to search for draw handle with specified option (string) or just sequence id

Source:

(private) getDrawSettings()

Provide draw settings for specified class or kind

Source:

(private) getEarthProjectionFunc()

Returns coordinates transformation func

Source:

(private) getElementCanvPainter(dom)

Returns canvas painter (if any) for specified HTML element

Source:
Parameters:
Name Type Description
dom string | object

id or DOM element

(private) getElementMainPainter(dom)

Returns main painter (if any) for specified HTML element - typically histogram painter

Source:
Parameters:
Name Type Description
dom string | object

id or DOM element

(private) getElementRect(elem, kindopt)

Returns visible rect of element

Description:
  • kind = 'bbox' use getBBox, works only with SVG kind = 'full' - full size of element, using getBoundingClientRect function kind = 'nopadding' - excludes padding area With node.js can use 'width' and 'height' attributes when provided in element

Source:
Parameters:
Name Type Attributes Description
elem object

d3.select object with element

kind string <optional>

which size method is used

(private) getGrayColors()

Source:

(private) getHImpl()

Returns real histogram impl

Source:

(private) getHPainter()

Returns current hierarchy painter object

Source:

(private) getHistPainter3DCfg() → {Object}

Provides 3D rendering configuration from histogram painter

Source:
Returns:

with scene, renderer and other attributes

Type
Object

(private) getIntersectStack()

Return stack for the item from list of intersection

Source:

(private) getMaterialArgs()

Source:

(private) getMethods()

Returns methods for given typename

Source:

(private) getNodeKind()

Analyze TGeo node kind

Description:
  • 0 - TGeoNode 1 - TEveGeoNode -1 - unsupported

Source:
Returns:

detected node kind

(private) getNodeMatrix()

Creates transformation matrix for TGeoNode

Description:
  • created after node visibility flag is checked and volume cut is performed

Source:

(private) getObjectName()

Returns geo object name

Description:
  • Can appends some special suffixes

Source:

(private) getPairStreamer()

Function creates streamer for std::pair object

Source:

(private) getPromise()

Provide promise in any case

Source:

(private) getRGBfromTColor()

Produces rgb code for TColor object

Source:

(private) getRender3DKind(render3dopt, is_batchopt) → {value}

Source:
Parameters:
Name Type Attributes Description
render3d value <optional>

preconfigured value, will be used if applicable

is_batch value <optional>

is batch mode is configured

Returns:
  • rendering kind, see constants.Render3D
Type
value

(private) getRootColors()

Get list of colors

Source:

(private) getShapeIcon()

provide icon name for the shape

Source:

(private) getSizeStr()

Return size as string with suffix like MB or KB

Source:

(private) getSvgLineStyle()

Get svg string for specified line style

Source:

(private) getTF1Value()

Provide TF1 value

Description:
  • First try evaluate, if not possible - check saved buffer

Source:

(private) getTimeGMT()

Return true when GMT option configured in time format

Source:

(private) getTimeOffset()

Return time offset value for given TAxis object

Source:

(private) getTreeBranch() → {Object}

Get branch with specified id

Description:
  • All sub-branches checked as well

Source:
Returns:

branch

Type
Object

(private) getTypeId()

Returns type id by its name

Source:

(private) get_touch_pointers()

Return pointers on touch event

Source:

graph2DTooltip()

Function handles tooltips in the mesh

Source:

hexMD5(s) → {string}

Encodes input string as Hex encoded string

.

Description:
  • Encodes input string as Hex encoded string

Source:
Parameters:
Name Type Description
s string

Input string

Returns:

Hex encoded string

Type
string

(private) highlightBin3D()

Hilight bin in frame painter 3D drawing

Source:

(async) httpRequest(url, kind, post_dataopt) → {Promise}

Submit asynchronoues http request

Description:
  • Following requests kind can be specified:

    • 'bin' - abstract binary data, result as string
    • 'buf' - abstract binary data, result as ArrayBuffer (default)
    • 'text' - returns req.responseText
    • 'object' - returns parse(req.responseText)
    • 'multi' - returns correctly parsed multi.json request
    • 'xml' - returns req.responseXML
    • 'head' - returns request itself, uses 'HEAD' request method
    • 'post' - creates post request, submits req.send(post_data)
    • 'postbuf' - creates post request, expectes binary data as response
Source:
Example
import { httpRequest } from 'https://root.cern/js/latest/modules/core.mjs';
httpRequest('https://root.cern/js/files/thstack.json.gz', 'object')
      .then(obj => console.log(`Get object of type ${obj._typename}`))
      .catch(err => console.error(err.message));
Parameters:
Name Type Attributes Description
url string

URL for the request

kind string

kind of requested data

post_data string <optional>

data submitted with post kind of request

Returns:

Promise for requested data, result type depends from the kind

Type
Promise

(async, private) injectCode() → {Promise}

Inject javascript code

Description:
  • Replacement for eval

Source:
Returns:

when code is injected

Type
Promise

(private) injectGeoStyle()

Create geo-related css entries

Source:

(private) injectStyle(code)

Inject style

Source:
Parameters:
Name Type Description
code String

css string

(private) isArrayProto() → {Number}

Check if prototype string match to array (typed on untyped)

Source:
Returns:

0 - not array, 1 - regular array, 2 - typed array

Type
Number

isBatchMode()

Indicates if running in batch mode

Source:

(private) isDefaultStatPosition()

Returns true if stat box on default place and can be adjusted

Source:

(private) isFunc()

Check if argument is a Function

Source:

isNodeJs()

Indicates if running inside Node.js

Source:

(private) isObject()

Check if argument is a not-null Object

Source:

(private) isPlainText()

Check if plain text

Source:

(private) isPromise()

Check if object is a Promise

Source:

(private) isRootCollection(lst, typenameopt)

Returns true if object represents basic ROOT collections

Description:
  • Checks if type is TList or TObjArray or TClonesArray or TMap or THashList

Source:
Parameters:
Name Type Attributes Description
lst object

object to check

typename string <optional>

or just typename to check

(private) isSameStack()

Checks if two stack arrays are identical

Source:

(private) isStr()

Check if argument is a atring

Source:

(private) is_dragging()

Check if dragging performed currently

Source:

(private) keysHierarchy()

Create hierarchy of TKey lists in file or sub-directory

Source:

(private) listHierarchy()

Create hierarchy elements for TList object

Source:

(async, private) loadMathjax()

Load MathJax functionality,

Description:
  • one need not only to load script but wait for initialization

Source:

(async, private) loadOpenui5() → {Promise}

load openui5

Source:
Returns:

for loading ready

Type
Promise

(async) loadScript(url) → {Promise}

Load script or CSS file into the browser

Source:
Parameters:
Name Type Description
url String

script or css file URL (or array, in this case they all loaded sequentially)

Returns:
Type
Promise

(private) makeEveGeometry()

Create single shape from EVE7 render date

Source:

(async) makeImage(args) → {Promise}

Create SVG/PNG/JPEG image for provided object.

Description:
  • Function especially useful in Node.js environment to generate images for supported ROOT classes, but also can be used from web browser

Source:
Example
// how makeImage can be used in node.js
import { openFile, makeImage } from 'jsroot';
let file = await openFile('https://root.cern/js/files/hsimple.root');
let object = await file.readObject('hpxpy;1');
let png64 = await makeImage({ format: 'png', object, option: 'colz', width: 1200, height: 800 });
let pngbuf = await makeImage({ format: 'png', as_buffer: true, object, option: 'colz', width: 1200, height: 800 });
Parameters:
Name Type Description
args object

function settings

Properties
Name Type Attributes Default Description
object object

object for the drawing

format string <optional>
'svg'

image format like 'svg' (default), 'png' or 'jpeg'

option string <optional>
''

draw options

width number <optional>
1200

image width

height number <optional>
800

image height

as_buffer boolean <optional>
false

returns image as Buffer instance, can store directly to file

use_canvas_size boolean <optional>
false

if configured used size stored in TCanvas object

Returns:

with image code - svg as is, png/jpeg as base64 string or buffer (if as_buffer) specified

Type
Promise

(private) makeMethodsList()

create fast list to assign all methods to the object

Source:

(async) makeSVG(args) → {Promise}

Create SVG image for provided object.

Description:
  • Function especially useful in Node.js environment to generate images for supported ROOT classes

Source:
Example
// how makeSVG can be used in node.js
import { openFile, makeSVG } from 'jsroot';
let file = await openFile('https://root.cern/js/files/hsimple.root');
let object = await file.readObject('hpxpy;1');
let svg = await makeSVG({ object, option: 'lego2,pal50', width: 1200, height: 800 });
Parameters:
Name Type Description
args object

function settings

Properties
Name Type Attributes Default Description
object object

object for the drawing

option string <optional>

draw options

width number <optional>
1200

image width

height number <optional>
800

image height

use_canvas_size boolean <optional>
false

if configured used size stored in TCanvas object

Returns:

with svg code

Type
Promise

(private) makeTranslate()

Return translate string for transform attribute of some svg element

Source:
Returns:

string or null if x and y are zeros

(private) makeViewerGeometry()

Create single shape from geometry veiwer render date

Source:

(private) markAsStreamerInfo()

tag item in hierarchy painter as streamer info

Description:
  • this function used on THttpServer to mark streamer infos list as fictional TStreamerInfoList class, which has special draw function

Source:

(private) md5cmn()

Source:

(private) md5ff()

Source:

(private) md5gg()

Source:

(private) md5hh()

Source:

(private) md5ii()

Source:

(private) numGeometryFaces(geom)

Returns number of faces for provided geometry

Source:
Parameters:
Name Type Description
geom Object

can be BufferGeometry, CsgGeometry or interim array of polygons

(private) numGeometryVertices(geom)

Returns number of faces for provided geometry

Source:
Parameters:
Name Type Description
geom Object

can be BufferGeometry, CsgGeometry or interim array of polygons

(private) objectHierarchy()

Create hierarchy for arbitrary object

Source:

(private) onlineHierarchy()

central function for expand of all online items

Source:

openFile(arg) → {object}

Open ROOT file for reading

Description:
  • Generic method to open ROOT file for reading Following kind of arguments can be provided:

    • string with file URL (see example). In node.js environment local file like 'file://hsimple.root' can be specified
    • File instance which let read local files from browser
    • ArrayBuffer instance with complete file content
    • FileProxy let access arbitrary files via tiny proxy API
Source:
Example
import { openFile } from 'https://root.cern/js/latest/modules/io.mjs';
let f = await openFile('https://root.cern/js/files/hsimple.root');
console.log(`Open file ${f.getFileName()}`);
Parameters:
Name Type Description
arg string | object

argument for file open like url, see details

Returns:
  • Promise with TFile instance when file is opened
Type
object

parse(json) → {object}

Should be used to parse JSON string produced with TBufferJSON class

Description:
  • Replace all references inside object like { "$ref": "1" }

Source:
Parameters:
Name Type Description
json object | string

object where references will be replaced

Returns:

parsed object

Type
object

(private) parseAsArray()

Parse string value as array.

Description:
  • It could be just simple string: 'value' or array with or without string quotes: [element], ['elem1',elem2]

Source:

(private) parseLatex()

use together with normal elements

.

Description:
  • use together with normal elements

Source:

parseMulti(json) → {Array}

Parse response from multi.json request

Description:
  • Method should be used to parse JSON code, produced by multi.json request of THttpServer

Source:
Parameters:
Name Type Description
json string

string to parse

Returns:

array of parsed elements

Type
Array

(private) postponePromise()

Postpone func execution and return result in promise

Source:

(private) produceLatex()

use together with normal elements

.

Description:
  • use together with normal elements

Source:

(async, private) produceMathjax()

Produce text with MathJax

Source:

(private) produceNormal()

Create normal to plane, defined with three points

Source:

(private) producePlainText()

Just add plain text to the SVG text elements

Source:

produceRenderOrder(toplevel, origin, method)

Set rendering order for created hierarchy

Description:
  • depending from provided method sort differently objects

Source:
Parameters:
Name Type Description
toplevel

top element

origin

camera position used to provide sorting

method

name of sorting method like 'pnt', 'ray', 'size', 'dflt'

(private) produceTAxisLogScale()

Create log scale for axis bins

Source:

(private) proivdeEvalPar()

Assign evalPar function for TF1 object

Source:

(private) projectGeometry()

Try to create projected geometry

Source:

(private) provideMenu()

provide menu for geo object

Source:

(private) provideObjectInfo(obj)

Provides info about geo object, used for tooltip info

Source:
Parameters:
Name Type Description
obj Object

any kind of TGeo-related object like shape or node or volume

(private) provideVisStyle()

provide css style for geo object

Source:

rawMD5(s) → {string}

Encodes input string as raw MD5 string

.

Description:
  • Encodes input string as raw MD5 string

Source:
Parameters:
Name Type Description
s string

Input string

Returns:

Raw MD5 string

Type
string

(private) readLocalStorage()

Read object from storage with specified name

Source:

(private) readMapElement()

Function used in streamer to read std::map object

Source:

(private) readSettings(only_check, nameopt)

Read JSROOT settings from specified cookie parameter

Source:
Parameters:
Name Type Attributes Default Description
only_check Boolean false

when true just checks if settings were stored before with provided name

name String <optional>
settings

storage name, 'settings' by default

(private) readStyle(only_checkopt, nameopt)

Read JSROOT gStyle object from local storage

Source:
Parameters:
Name Type Attributes Default Description
only_check Boolean <optional>
false

when true just checks if settings were stored before with provided name

name String <optional>
style

storage name, 'style' by default

(private) readStyleFromURL()

Read style and settings from URL

Source:

(private) readVectorElement()

Function to read vector element in the streamer

Source:

reconstructObject(class_name, obj_rawdata, sinfo_rawdata) → {object}

Reconstruct ROOT object from binary buffer

Description:
  • Method can be used to reconstruct ROOT objects from binary buffer which can be requested from running THttpServer, using root.bin request To decode data, one has to request streamer infos data after object data as it shown in example.

    Method provided for convenience only to see how binary IO works. It is strongly recommended to use root.json request to get data directly in JSON format

Source:
Example
import { httpRequest } from 'http://localhost:8080/jsrootsys/modules/core.mjs';
import { reconstructObject } from 'http://localhost:8080/jsrootsys/modules/io.mjs';

let obj_data = await httpRequest('http://localhost:8080/Files/job1.root/hpx/root.bin', 'buf');
let si_data = await httpRequest('http://localhost:8080/StreamerInfo/root.bin', 'buf');
let histo = await reconstructObject('TH1F', obj_data, si_data);
console.log(`Get histogram with title = ${histo.fTitle}`);

// request same data via root.json request
httpRequest('http://localhost:8080/Files/job1.root/hpx/root.json', 'object')
           .then(histo => console.log(`Get histogram with title = ${histo.fTitle}`));
Parameters:
Name Type Description
class_name string

Class name of the object

obj_rawdata binary

data of object root.bin request

sinfo_rawdata binary

data of streamer info root.bin request

Returns:
  • created JavaScript object
Type
object

(async) redraw(dom, obj, opt) → {Promise}

Redraw object in specified HTML element with given draw options.

Description:
  • If drawing was not done before, it will be performed with draw. Otherwise drawing content will be updated

Source:
Example
import { openFile } from 'https://root.cern/js/latest/modules/io.mjs';
import { draw, redraw } from 'https://root.cern/js/latest/modules/draw.mjs';
let file = await openFile('https://root.cern/js/files/hsimple.root');
let obj = await file.readObject('hpxpy;1');
await draw('drawing', obj, 'colz');
let cnt = 0;
setInterval(() => {
   obj.fTitle = `Next iteration ${cnt++}`;
   redraw('drawing', obj, 'colz');
}, 1000);
Parameters:
Name Type Description
dom string | object

id of div element to draw or directly DOMElement

obj object

object to draw, object type should be registered before with addDrawFunc

opt string

draw options

Returns:

with painter object

Type
Promise

(protected) registerForResize(handle, delayopt)

Register handle to react on window resize

Description:
  • function used to react on browser window resize event While many resize events could come in short time, resize will be handled with delay after last resize event

Source:
Parameters:
Name Type Attributes Description
handle object | string

can be function or object with checkResize function or dom where painting was done

delay number <optional>

one could specify delay after which resize event will be handled

(private) registerMethods()

Add methods for specified type.

Description:
  • Will be automatically applied when decoding JSON string

Source:

(private) remapSymbolTtfCode()

Return code for symbols from symbols.ttf

Description:
  • Used in PDF generation

Source:

(private) remove3DMeshes()

Remove 3D meshed for specified painter

Source:

(private) render3D(tmout)

call 3D rendering of the frame

Description:
  • Timeout used to avoid multiple rendering of the picture when several 3D drawings superimposed with each other. If tmeout <= 0, rendering performed immediately If tmout === -1111, immediate rendering with SVG renderer is performed

Source:
Parameters:
Name Type Description
tmout number

specifies delay, after which actual rendering will be invoked

(private) repairMathJaxSvgSize()

Workaround to fix size attributes in MathJax SVG

Source:

(private) replaceSymbolsInTextNode()

Reformat text node if it includes greek or special symbols

Description:
  • Used in PDF generation where greek symbols are not available

Source:

resize(dom, arg)

Check resize of drawn element

Description:
  • As first argument dom one should use same argument as for the drawing As second argument, one could specify 'true' value to force redrawing of the element even after minimal resize Or one just supply object with exact sizes like { width:300, height:200, force:true };

Source:
Example
import { resize } from 'https://root.cern/js/latest/modules/base/ObjectPainter.mjs';
resize('drawing', { width: 500, height: 200 });
resize(document.querySelector('#drawing'), true);
Parameters:
Name Type Description
dom string | object

id or DOM element

arg boolean | object

options on how to resize

(private) resize3D()

Check is 3D drawing need to be resized

Source:

rstr2binl(input) → {Array.<number>}

Convert a raw string to an array of little-endian words Characters >255 have their high-byte silently ignored.

Description:
  • Convert a raw string to an array of little-endian words Characters >255 have their high-byte silently ignored.

Source:
Parameters:
Name Type Description
input string

Raw input string

Returns:

Array of little-endian words

Type
Array.<number>

rstr2hex(input) → {string}

Convert a raw string to a hex string

.

Description:
  • Convert a raw string to a hex string

Source:
Parameters:
Name Type Description
input string

Raw input string

Returns:

Hex encoded string

Type
string

rstrMD5(s) → {string}

Calculate the MD5 of a raw string

.

Description:
  • Calculate the MD5 of a raw string

Source:
Parameters:
Name Type Description
s string

Input string

Returns:

Raw MD5 string

Type
string

(private) safeAdd()

Source:

(async, private) saveFile()

Function store content as file with filename

Source:

(private) saveLocalStorage()

Save object in local storage

Source:

(private) saveSettings(expiresopt, nameopt)

Save JSROOT settings in local storage

Source:
Parameters:
Name Type Attributes Default Description
expires Number <optional>
365

delete settings when negative

name String <optional>
settings

storage name, 'settings' by default

(private) saveStyle(expiresopt, nameopt)

Save JSROOT gStyle object in local storage

Source:
Parameters:
Name Type Attributes Default Description
expires Number <optional>
365

delete style when negative

name String <optional>
style

storage name, 'style' by default

(private) selectActivePad(args)

Set active pad painter

Description:
  • Normally be used to handle key press events, which are global in the web browser

Source:
Parameters:
Name Type Description
args object

functions arguments

Properties
Name Type Attributes Description
pp object

pad painter

active boolean <optional>

is pad activated or not

(private) selectgStyle()

Select predefined style

Source:

(private) set3DOptions()

Set options used for 3D drawings

Source:

(private) setBatchMode()

Set batch mode

Source:

(private) setCameraPosition()

Set default camera position

Source:

setDefaultDrawOpt()

Set default draw option for provided class

Source:
Example
import { setDefaultDrawOpt } from 'https://root.cern/js/latest/modules/draw.mjs';
  setDefaultDrawOpt('TH1', 'text');
  setDefaultDrawOpt('TH2', 'col');

(private) setGeoBit()

Set fGeoAtt bit

Source:

(private) setHPainter()

Set hierarchy painter object

Source:

setHistogramTitle()

Set histogram title

Description:
  • Title may include axes titles, provided with ';' symbol like "Title;x;y;z"

Source:

(private) setInvisibleAll()

Implementation of TGeoVolume::InvisibleAll

Source:

(private) setPainterTooltipEnabled()

Configure tooltip enable flag for painter

Source:

(private) setSaveFile()

Function store content as file with filename

Source:

(private) setStoragePrefix()

Set custom prefix for the local storage

Source:

(private) showPainterMenu()

Fill and show context menu for painter object

Source:

(private) showProgress(msg, tmoutopt, click_handleopt)

Display progress message in the left bottom corner.

Description:
  • Previous message will be overwritten if no argument specified, any shown messages will be removed

Source:
Parameters:
Name Type Attributes Description
msg string

message to display

tmout number <optional>

optional timeout in milliseconds, after message will disappear

click_handle function <optional>

optional handle to process click events

str2rstrUTF8(input) → {string}

Encode a string as UTF-8

.

Description:
  • Encode a string as UTF-8

Source:
Parameters:
Name Type Description
input string

Input string

Returns:

UTF8 string

Type
string

(async, private) svgToImage(svg, image_formatopt, as_bufferopt) → {Promise}

Create image based on SVG

Source:
Parameters:
Name Type Attributes Description
svg string

svg code of the image

image_format string <optional>

image format like 'png', 'jpeg' or 'webp'

as_buffer boolean <optional>

return Buffer object for image

Returns:

with produced image in base64 form or as Buffer (or canvas when no image_format specified)

Type
Promise

(async, private) svgToPDF() → {Promise}

Create pdf for existing SVG element

Source:
Returns:

with produced PDF file as url string

Type
Promise

(private) taskHierarchy()

Create hierarchy elements for TTask object

Source:

(private) testAxisVisibility()

Text 3d axis visibility

Source:

(private) testGeoBit()

Test fGeoAtt bits

Source:

(async, private) testInteractivity()

test interactive features of JSROOT drawings

Description:
  • used in https://github.com/linev/jsroot-test

Source:

(async, private) testMouseWheel()

test mouse wheel zooming features

Source:

(async, private) testMouseZooming()

test mouse zooming features

Source:

(async, private) testTouchZooming()

test touch zooming features

Source:

(async, private) testZooming()

test zooming features

Source:

(private) toHex()

Covert value between 0 and 1 into hex, used for colors coding

Source:

toJSON(obj, spacingopt) → {string}

Method converts JavaScript object into ROOT-like JSON

Description:
  • When performed properly, JSON can be used in TBufferJSON::fromJSON() method to read data back with C++ Or one can again parse json with parse function

Source:
Example
import { openFile, draw, toJSON } from 'https://root.cern/js/latest/modules/main.mjs';
let file = await openFile('https://root.cern/js/files/hsimple.root');
let obj = await file.readObject('hpxpy;1');
obj.fTitle = 'New histogram title';
let json = toJSON(obj);
Parameters:
Name Type Attributes Description
obj object

JavaScript object to convert

spacing number <optional>

optional line spacing in JSON

Returns:

produced JSON code

Type
string

(private) toggleGeoBit()

Toggle fGeoAttBit

Source:

(private) translateLaTeX()

Simple replacement of latex letters

Source:

(private) translateMath()

Function translates ROOT TLatex into MathJax format

Source:

(async) treeDraw(args) → {Promise}

implementation of TTree::Draw

Source:
Parameters:
Name Type Description
args object | string

different setting or simply draw expression

Properties
Name Type Attributes Default Description
expr string

draw expression

cut string <optional>

cut expression (also can be part of 'expr' after '::')

drawopt string <optional>

draw options for result histogram

firstentry number <optional>
0

first entry to process

numentries number <optional>

number of entries to process, all by default

branch object <optional>

TBranch object from TTree itself for the direct drawing

progress function <optional>

function called during histogram accumulation with obj argument

Returns:

with produced object

Type
Promise

(async, private) treeDrawProgress()

Handle callback function with progress of tree draw

Source:

(private) treeHierarchy()

Create hierarchy of TTree object

Source:

(private) treeIOTest()

Performs generic I/O test for all branches in the TTree

Description:
  • Used when 'testio' draw option for TTree is specified

Source:

(async) treeProcess(tree, selector, argsopt) → {Promise}

Process selector for the tree

Description:
  • function similar to the TTree::Process

Source:
Parameters:
Name Type Attributes Description
tree object

instance of TTree class

selector object

instance of TSelector class

args object <optional>

different arguments

Properties
Name Type Attributes Description
firstentry number <optional>

first entry to process, 0 when not specified

numentries number <optional>

number of entries to process, all when not specified

Returns:

with TSelector instance

Type
Promise

(private) tryOpenOpenUI()

Tries to open ui5

Source:

(async, private) typesetMathjax()

Just typeset HTML node with MathJax

Source:

(private) unzoomHistogramYRange()

Unzoom preselected range for main histogram painter

Description:
  • Used with TGraph where Y zooming selected with fMinimum/fMaximum but histogram axis range can be wider. Or for normal histogram drawing when preselected range smaller than histogram range

Source:

(private) updateBrowserIcons()

update icons

Source: