JSROOT Click Handling

Hello,

I was wondering if anyone had a simple example of handling clicking on a JSROOT plot. Is possible to initiate some event by clicking on a bin for example?

Thanks,
Josh

Hi Josh,

There are two variants to provide user actions - user-defined tooltip handler:

https://root.cern/js/latest/api.htm#custom_html_tooltip_hanlder
https://root.cern/js/latest/api.htm#custom_html_tooltip_hanlder_src

And custom zoom handler:

https://root.cern/js/latest/api.htm#custom_html_zooming

There is no event handler with mouse click.
In that situation and for that kind of events you want to have such handler?

Regards,
Sergey

Hello Sergey,

Thanks for the quick reply. What I was envisioning was clicking on a bin in a histogram and loading a new page that might display more detailed information about the bin in question. I would of course handle the output and display of the second page what I was looking for is just the clicking on the bin and getting basic stats about it.

Cheers,
Josh

Hi Josh,

This is not yet supported.
Now in most cases click on histogram bin connected with zooming or moving of histogram display.
I will check if this can be implemented.

Regards,
Sergey

Hi Josh,

I add new functionality to the dev version. Now one can assign click and double click handlers.
Example see here:

http://jsroot.gsi.de/dev/api.htm#custom_html_tooltip_hanlder
http://jsroot.gsi.de/dev/api.htm#custom_html_tooltip_hanlder_src

In close future (approx end of October) this will be in next 5.6.0 release.

Regards,
Sergey

Wow, thanks for such a quick turnaround on the implementation, Sergey!

Be aware - it is now working only for 2D plots, probably I will implement support for lego plots in the future

Using the latest dev works great for 2D. An implementation for 1D histos would be greatly appreciated.

Thanks again for implementing this for 2D so quickly.

Josh

You misunderstood me - 2D means drawing of normal canvas without WebGL.
All basic classes (TH1/TH2, TGraph, …) should work now with such handlers

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.