Listeners are how we get information out of a Vega chart and into the JavaScript environment. To do this, we specify handler-functions to run whenever a certain signal changes or an event fires.
vw_add_signal_listener(x, name, handler_body) vw_add_data_listener(x, name, handler_body) vw_add_event_listener(x, event, handler_body)
| x | vegawidget object to be monitored |
|---|---|
| name |
|
| handler_body |
|
| event |
|
modified copy of vegawidget object x
The handler_body can be the text of the body of a JavaScript function;
the arguments to this function will vary according to the type of listener
you are adding:
signal-handler and data-handler arguments: name, value
event-handler arguments: event, item
This package offers some functions to make it easier to build JavaScript
handler functions from R: vw_handler_signal(), vw_handler_data(),
and vw_handler_event(). You can pipe one of these functions to
vw_handler_add_effect() to perform side-effects on the result.