Skip to contents

Create an Echart

Usage

echartr(
  option = list(),
  on = NULL,
  dispatch = NULL,
  listen = NULL,
  elementId = NULL,
  update = FALSE
)

Arguments

option

list-tree representation of echarts option argument, see https://echarts.apache.org/en/option.html

on

list of event listeners to register, see https://echarts.apache.org/en/api.html#echartsInstance.on

dispatch

list of actions to dispatch immediately, see [][https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction]

listen

character vector of events to include in Shiny input, any of https://echarts.apache.org/en/api.html#events

Event output is available as input$<outputId>_<event>. For mouse events, event data is limited.

elementId

id attribute of HTML element

update

logical, whether to update the existing chart rather than creating a new one

Event listeners

https://echarts.apache.org/en/api.html#events

Event listeners can be registered via the on argument. Each listener is a named list, for example:

echartr(
 option = ...,
 on = list(
   list(
     eventName = "click",
     handler = htmlwidgets::JS("params => console.log(params)")
   ),
   list(
     eventName = "selectchanged",
     query = ,
     handler = htmlwidgets::JS("function(params) {
       console.log(x);
     }")
   )
 )
)

The context for the handler is the Echart instance - this can be accessed within the handler via this.context