ABSTRACT

An important thing to know about when doing any sort of web development is how to open and navigate to the web browser’s developer tools. Through the developer tools, a JS console can be accessed to run and test out JS code, inspect and debug the JS/CSS/HTML code behind a website, query components of the Document Object Model (DOM), inspect network traffic, and much more. One way to write a custom event handler for a plotly graph is to leverage the onRender() function from the htmlwidgets package. This R function accepts a JS function as a string and calls that function when the widget is done rendering in the browser. The JS function needs (at least) one argument, el, which is the DOM element containing the plotly graph.