Skip to contents

VChart events

Usage

v_event(vc, name, params, fun, ...)

Arguments

vc

A chart initialized with vchart().

name

Name of the event, e.g. "click".

params

Parameters to specifically monitor events in a certain part of the chart.

fun

JavaScript function executed when the event occurs.

...

Not used.

Value

A vchart() htmlwidget object.

Examples


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);",
      "}"
    )
  )