@ndmspc/react-jsroot
v0.1.1
Published
Made with create-react-library
Downloads
6
Readme
@ndmspc/react-jsroot
Made with create-react-library
Install
npm install --save @ndmspc/react-jsroot
Usage
import React, { useState } from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
import { localStore, StoreProvider } from '@ndmspc/react-ndmbase'
import {
JSROOTProvider,
JSROOTExample,
JSROOTDisplayFromFile,
JSROOTBrowser
} from '@ndmspc/react-jsroot'
let store = {
timeoutStore: localStore(),
filesStore: localStore(),
drawStore: localStore(),
padsStore: localStore()
}
function App() {
const [options] = useState(['', 'fixed', 'proX', 'proY'])
function MyHistHover(info) {
if (!info) {
return false
}
console.log('Hover: ' + info.binx + ' ' + info.biny)
return true
}
function MyHistClick(info) {
if (!info) {
return false
}
console.log('Click: ' + info.binx + ' ' + info.biny)
return true
}
function MyHistDblClick(info) {
if (!info) {
return false
}
console.log('DblClick: ' + info.binx + ' ' + info.biny)
return true
}
return (
<StoreProvider store={store}>
<JSROOTProvider src='https://root.cern.ch/js/latest/scripts/JSRoot.core.js'>
<Route exact path='/example' component={JSROOTExample} />
<Route exact path='/browser'>
<JSROOTBrowser
id='hist1'
filename='https://root.cern.ch/js/files/hsimple.root'
obj='hpxpy;1'
drawOptions='colz'
displayType='simple'
/>
</Route>
<Route exact path='/projections'>
<JSROOTDisplayFromFile
id='dff'
onHover={MyHistHover}
onClick={MyHistClick}
onDblClick={MyHistDblClick}
options={options}
/>
</Route>
<Redirect to='/example' from='/' />
</Switch>
</JSROOTProvider>
</StoreProvider>
)
}
export default App