v_event | R Documentation |
VChart events
v_event(vc, name, params, fun, ...)
vc |
A chart initialized with |
name |
Name of the event, e.g. |
params |
Parameters to specifically monitor events in a certain part of the chart. |
fun |
JavaScript function executed when the event occurs. |
... |
Not used. |
A vchart()
htmlwidget
object.
library(vchartr)
vchart(top_generation) %>%
v_bar(aes(country, electricity_generation)) %>%
v_event(
name = "click",
params = list(level = "mark", type = "bar"),
fun = JS(
"e => {",
" console.log(e);",
" alert(e.datum.x);",
"}"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.