I am using R htmlwidget package, which save plotly graph in the form of html.The function htmlwidget::savewidget()
save graph as a html file. Now we need to include a custom js file to the plotly html file generated by htmlwidget::savewidget()
for additional operation, like clicking on the graph etc ...
e.g My custom.js file contains the following code.
<script type="text/javascript">
$( document ).ready(function() {
$('#htmlwidget_container').on('plotly_click', function(data){
alert('You clicked this Plotly chart!');
});
});
</script>