sticker

sticker

ECharts 4 for R. Official documentation:

Installation

You can install echarts4r from github with:

# install.packages("devtools")
devtools::install_github("JohnCoene/echarts4r")

Features

Chart types

  • Bar
  • Line
  • Area
  • Step
  • Scatter
  • Effect Scatter
  • Candlestick
  • Funnel
  • Sankey
  • Graph
  • Heatmap
  • Parallel
  • Pie
  • Tree
  • Treemap
  • River
  • Sunburst
  • Boxplot
  • Calendar
  • Gauge
  • Radar
  • Polar
  • wordcloud
  • liquidFill
  • Map
  • Statistical
  • Pictoral
  • Line 3D
  • Bar 3D
  • Scatter 3D
  • Flow GL
  • Graph GL
  • Map 3D
  • Geo 3D
  • Globe 3D

Other

  • Proxies (*_p)
  • Themes
  • Built-in brush
  • Animations

Options

ECharts version 4 comes with hundreds if not thousands of options, it’s neigh impossible to list them all (see this issue). Though not listed in the documentation as parameters, all options are available, you can pass the aforementioned options as additional arguments through the three dot construct (...): the list of possible options can be found in the See Also section of each function; browse the website to see some examples.

Examples

Some of what you can do with echarts4r.

library(echarts4r)

# with negative
USArrests %>% 
  dplyr::mutate(
    State = row.names(.),
    Rape = -Rape
  ) %>% 
  e_charts(State) %>% 
  e_area(Murder) %>%
  e_bar(Rape, name = "Sick basterd", x.index = 1) %>% # second y axis 
  e_mark_line("Sick basterd", data = list(type = "average")) %>% 
  e_mark_point("Murder", data = list(type = "max")) %>% 
  e_tooltip(trigger = "axis")
# river
dates <- seq.Date(Sys.Date() - 30, Sys.Date(), by = "day")

df <- data.frame(
  dates = dates,
  apples = runif(length(dates)),
  bananas = runif(length(dates)),
  pears = runif(length(dates))
)

df %>% 
  e_charts(dates) %>% 
  e_river(apples) %>% 
  e_river(bananas) %>% 
  e_river(pears) %>% 
  e_tooltip(trigger = "axis")
# graph
value <- rnorm(20, 10, 2)

nodes <- data.frame(
  name = sample(LETTERS, 20),
  value = value,
  size = value,
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 50, replace = TRUE),
  target = sample(nodes$name, 50, replace = TRUE),
  stringsAsFactors = FALSE
)

e_charts() %>% 
  e_graph() %>% 
  e_graph_nodes(nodes, name, value, size) %>% 
  e_graph_edges(edges, source, target) %>% 
  e_title("Graph") %>% 
  e_tooltip()
# 3D bars
url <- paste0("https://ecomfe.github.io/echarts-examples/",
              "public/data-gl/asset/data/population.json")
data <- jsonlite::fromJSON(url)
data <- as.data.frame(data)
names(data) <- c("lon", "lat", "value")

data %>% 
  e_charts(lon) %>% 
  e_geo_3d() %>% 
  e_bar_3d(lat, value, coord.system = "geo3D") %>% 
  e_visual_map()