Capture events in shiny.

capture_event(g, event, callback = NULL, when = c("on", "once", "off"))

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

event

Name of event to trigger the callback.

callback

A callback function to run when the event is fired, if NULL then a default one is created, see details.

when

When the event should be triggered.

Details

The callback function should accept a single argument; the event data. If no callback function is passed (NULL) then one is generated. The generated callback function sets a shiny input <chartId>_<eventName> with the event data.

Examples

g2(iris, asp(Sepal.Width, Sepal.Length)) %>%
  fig_point() %>%
  capture_event("point:click")