# Plotly.js events in ggplotly + Shiny

**URL:** <https://community.plotly.com/t/plotly-js-events-in-ggplotly-shiny/1391>\
**Category:** Plotly R\
**Created:** [June 27, 2016, 2:11pm UTC](https://community.plotly.com/t/plotly-js-events-in-ggplotly-shiny/1391 "2016-06-27T14:11:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bostonwalker](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@bostonwalker](https://community.plotly.com/u/bostonwalker)\
**Post date:** [June 27, 2016, 2:11pm UTC](https://community.plotly.com/t/plotly-js-events-in-ggplotly-shiny/1391/1 "2016-06-27T14:11:46Z")

</div>

I can’t seem to get any events to work properly using ggplotly. I have two use cases:

1. I want my application to perform an action if a user clicks a data point. Following the documentation [here](https://plot.ly/javascript/click-events/), I tried to intercept “plotly\_click” events. With Shiny and ggplotly, I don’t control the lifecycle of my plots directly, so using jQuery:

… gives me nothing. Which is strange, because chart6 is the parent div of the plot-container element.

```
$('*').on('plotly_click', function(evt) {
    console.log(evt);
});

```

… gives me m.Event {type: “plotly\_click”, …}. But evt has no points attribute, and evt.data is explicitly undefined. So the event has no information identifying which point I clicked on!

2 ) I want to disable the default hoverinfo/tooltip, and use the evt to create my own.

```
$('*').on('plotly_hover', function(evt) {
    console.log(evt);
});

```

… gives me m.Event {type: “plotly\_hover”, …}. But again there is no useful information in this event!

Is ggplotly even compatible with plotly.js events?

---

<div class="post-metadata">

**Author:** ![jack](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jack/32/11_2.png) [@jack](https://community.plotly.com/u/jack)\
**Post date:** [January 5, 2017, 9:39pm UTC](https://community.plotly.com/t/plotly-js-events-in-ggplotly-shiny/1391/2 "2017-01-05T21:39:30Z")

</div>

Hiya! Plotly now has improved and consolidated Plotly.js event documentation here:

> **[Event Handlers](https://plot.ly/javascript/plotlyjs-events/)**
>
> Definitions and examples of how to use Plotly.js event handlers to add additional interactive capabilities to Plotly charts.

Please feel free to suggest documentation improvements in a pull request:

[https://github.com/plotly/documentation/tree/source-design-merge/\_posts/plotly\_js/events](https://github.com/plotly/documentation/tree/source-design-merge/_posts/plotly_js/events)
