This document details more advanced usage of the echarts4r package.


Chart types are not only applicable to the standard 2D cartesian coordinate system, though most charts will default to the cartesian2d coordinate system they may be applied to others.

Let’s look at the heatmap. First a regular heatmap.

One could also plot the heatmap on different coordinates, such as a calendar by first adding a calendar with e_calendar then specifying coord.system = "calendar".

Another example, using polar coordinates, plot a line on 2D cartesian coordinates, then change to polar.

df %>% 
  e_charts(x) %>% 
  e_polar() %>% 
  e_angle_axis() %>% 
  e_radius_axis() %>% 
  e_line(y, coord.system = "polar", smooth = TRUE) 

There are numerous coordinate system available in echarts4r; globe, cartesian3d and polar to name a few.

Customise the Axis

Use multiple axis.

USArrests %>% 
  e_charts(Assault) %>% 
  e_line(Murder, smooth = TRUE) %>% 
  e_line(Rape, y.index = 1) %>%  # add secondary axis
  e_y_axis(spliLine = list(show = FALSE)) # hide split lines on first Y axis

Flip coordinates

Mark Points and Lines

Highlight points and lines on your plot.

USArrests %>% 
    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 = "min"))

Look for arguments

Look for more arguments, with echarts4r are often only one argument away from from what you want.

to radial:

Show labels

# with negative
USArrests %>% 
        State = row.names(.)
    ) %>% 
    dplyr::slice(1:10) %>% 
    e_charts(State) %>% 
    e_area(Murder, label = list(normal = list(show = TRUE)))