Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

echartsNJSON

To & From JSON


Description

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

Usage

e_inspect(e, json = FALSE, ...)

echarts_from_json(txt)

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

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

Create Interactive Graphs with 'Echarts JavaScript' Version 5

v0.4.0
Apache License (>= 2.0)
Authors
John Coene [aut, cre, cph], Wei Su [ctb], Helgasoft [ctb], Xianying Tan [ctb] (<https://orcid.org/0000-0002-6072-3521>)
Initial release
2021-03-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.