# JSROOT Click Handling

**URL:** <https://root-forum.cern.ch/t/jsroot-click-handling/30999>\
**Category:** ROOT\
**Tags:** jsroot\
**Created:** [October 5, 2018, 2:33pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999 "2018-10-05T14:33:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JHiltbrand](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@JHiltbrand](https://root-forum.cern.ch/u/JHiltbrand)\
**Post date:** [October 5, 2018, 2:33pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/1 "2018-10-05T14:33:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [October 5, 2018, 3:00pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/2 "2018-10-05T15:00:51Z")

</div>

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)  
[https://root.cern/js/latest/api.htm#custom\_html\_tooltip\_hanlder\_src](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](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

---

<div class="post-metadata">

**Author:** ![JHiltbrand](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@JHiltbrand](https://root-forum.cern.ch/u/JHiltbrand)\
**Post date:** [October 7, 2018, 4:33pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/3 "2018-10-07T16:33:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [October 7, 2018, 6:21pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/4 "2018-10-07T18:21:41Z")

</div>

Hi Josh,

> [@JHiltbrand](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [October 8, 2018, 5:12pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/5 "2018-10-08T17:12:07Z")

</div>

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)  
[http://jsroot.gsi.de/dev/api.htm#custom\_html\_tooltip\_hanlder\_src](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

---

<div class="post-metadata">

**Author:** ![JHiltbrand](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@JHiltbrand](https://root-forum.cern.ch/u/JHiltbrand)\
**Post date:** [October 8, 2018, 5:31pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/6 "2018-10-08T17:31:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [October 8, 2018, 8:06pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/7 "2018-10-08T20:06:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JHiltbrand](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@JHiltbrand](https://root-forum.cern.ch/u/JHiltbrand)\
**Post date:** [October 10, 2018, 11:44am UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/8 "2018-10-10T11:44:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [October 10, 2018, 1:58pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/9 "2018-10-10T13:58:35Z")

</div>

> [@JHiltbrand](#):
>
> An implementation for 1D histos would be greatly appreciated.

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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [October 24, 2018, 2:06pm UTC](https://root-forum.cern.ch/t/jsroot-click-handling/30999/10 "2018-10-24T14:06:13Z")

</div>

Closed on October 24, 2018, 2:06pm UTC

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