echartsNJSON: To & From JSON

Description Usage Arguments Details Value Note Examples

Description

Get JSON options from an echarts4r object and build one from JSON.

Usage

1
2
3

Arguments

e

An echarts4r object as returned by e_charts or a proxy as returned by echarts4rProxy.

json

Whether to return the JSON, otherwise returns a list.

...

Additional options to pass to toJSON.

txt

JSON character string, url, or file.

Details

txt should contain the full list of options required to build a chart. This is subsequently passed to the setOption ECharts (JavaScript) function.

Value

e_inspect Returns a list if json is FALSE and a JSON string otherwise. echarts_from_json returns an object of class echarts4r.

Note

Must be passed as last option.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
p <- cars %>%
  e_charts(dist) %>%
  e_scatter(speed, symbol_size = 10)

p # plot

# extract the JSON
json <- p %>%
  e_inspect(
    json = TRUE,
    pretty = TRUE
  )

# print json
json

# rebuild plot
echarts_from_json(json) %>%
  e_theme("dark") # modify

echarts4r documentation built on March 7, 2021, 5:06 p.m.