Skip to contents

Install Javascript plugin from URL source

Usage

ec.plugjs(wt = NULL, source = NULL, ask = FALSE)

Arguments

wt

A widget to add dependency to, see createWidget

source

URL or file:// of a Javascript plugin,
file name suffix is '.js'. Default is NULL.

ask

Boolean, to ask the user to download source if missing. Default is FALSE.

Value

A widget with JS dependency added if successful, otherwise input wt

Details

When source is URL, the plugin file is installed with an optional popup prompt.
When source is a file name (file://xxx.js), it is assumed installed and only a dependency is added.
Called internally by ec.init. It is recommended to use ec.init(load=...) instead of ec.plugjs.

Examples

# import map plugin and display two (lon,lat) locations
if (interactive()) {
  ec.init(preset= FALSE,
          geo = list(map= 'china-contour', roam= TRUE),
          series = list(list(
            type= 'scatter', coordinateSystem= 'geo',
            symbolSize= 9, itemStyle= list(color= 'red'),
            data= list(list(value= c(113, 40)), list(value= c(118, 39))) ))
  ) |> 
  ec.plugjs( paste0('https://raw.githubusercontent.com/apache/echarts/',
                    'master/test/data/map/js/china-contour.js') )
}