chartEvent: Trigger an event

Description Usage Arguments Examples

View source: R/lc.R

Description

This function is called whenever any interactive element of a chart is activated by clicking, marking, hovering, etc. In turn, it calls a corresponding callback function, if any has been specified. This function is meant to be used internally. However, an experienced user can still use it to simulate mouse events, even those triggered by non-existing elements. This function is a wrapper around method chartEvent of class LCApp.

Usage

1
chartEvent(d, chartId, layerId = "main", event, sessionId = .id, app = .app)

Arguments

d

Value that is used to identify an interactive element or its state. A single numeric index for a point or a line, vector or row and column indices of a cell for a heatmap, value for an input block (please, check lc_input for more details about input blocks and their values). It should be NULL for mouseout or marked events. NB: This function is called from the web page, and therefore all element indices start from zero as it happens in JavaScript.

chartId

ID of the chart.

layerId

ID of the layer. You can print IDs of all charts and their layers with listCharts.

event

Type of event. Must be one of "click", "mouseover", "mouseout", "marked", "labelClickRow", "labelClickCol", "clickPosition".

sessionId

ID of the session (opened client page) that triggered the event. The default value uses a local session variable. This must be a single session ID. You can get a list of IDs of all currently active with the method getSessionIds inherited from class App by LCApp. Possible errors in the evaluation of this argument are ignored.

app

Object of class LCApp for which the event was triggered. Note that this argument is here for internal use, and its default value is a variable stored in each session locally. If you are not using wrapper functions, it is preferred to call method chartEvent of an object of class LCApp.

Examples

1
2
3
x <- rnorm(50)
lc_scatter(x = x, y = 2*x + rnorm(50, 0.1), on_click = function(d) print(d))
chartEvent(51, "Chart1", "Layer1", "click")

rlc documentation built on Jan. 5, 2022, 1:11 a.m.