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)
vegawidget object to be monitored
character, name of the signal or dataset to be monitored
character or JS_EVAL, text of the body of
the JavaScript handler-function to be called when the signal or dataset
changes, or the event fires
character, name of the type of event to be monitored,
e.g. "click"
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.
vw_handler_signal(), vw_handler_data(), vw_handler_event(),
vw_handler_add_effect()
vega-view:
addSignalListener(),
addDataListener(),
addEventListener()