rchartsecharts4r

What's the geom_abline() equivalent in echarts4r?


I'm trying to plot a scatterplot using e_scatter with a benchmark line that should go from (0,0) to (1,1) on the chart

```
compare () %>% 
  tibble::rownames_to_column("Brand") %>% 
  e_charts(Benchmark) %>% 
  e_scatter(Actual,symbol_size = 10,bind = Name) %>% 
  e_labels(formatter = htmlwidgets::JS("function(params) {
  return(params.name)
      }")) %>% 
  e_mark_line(data = list(xAxis = 0)) %>% 
  e_tooltip()

```

Solution

  • compare() %>% 
      tibble::rownames_to_column("Brand") %>% 
      mutate(New = Benchmark) %>% 
      e_charts(Benchmark) %>% 
      e_scatter(Actual,symbol_size = 10,bind = Brand) %>% 
      e_labels(formatter = htmlwidgets::JS("function(params) {
      return(params.name)
    }")) %>% 
      e_lm(New~Benchmark) %>% 
      e_tooltip() %>% 
      e_axis_labels(x ="Benchmark", y = "Actual")