e_mark_line 符号和名称

Vla*_*lad 1 visualization r echarts4r

如何更改使用 e_mark_line 生成的线的标签?这是我的尝试,我希望它有自己的标签,而不是显示数字 200。

library(echarts4r)
library(tidyverse)    

line <- list(
        xAxis = 200
        , name = "label 1"
    )

USArrests %>% 
  e_charts(Assault) %>% 
  e_scatter(Murder, Rape) %>% 
  e_mark_line(data = line, symbol = "none", name = "label 2")
Run Code Online (Sandbox Code Playgroud)

由代码生成的图表

Joh*_*ene 6

用于标记线、点和区域的底层 echarts JavaScript 相当复杂。标题必须在 中指定data。在开发版本中,有一些与便利title相关的参数。

library(echarts4r)

cars %>% 
  e_charts(speed) %>% 
  e_scatter(dist, symbol_size = 5) %>% 
  e_legend(FALSE) %>% 
  # manual
  e_mark_line(data = list(xAxis = 7, symbol = "rect", label = list(formatter = "tortoise"))) %>%
  # convenience arguments in latest github version
  e_mark_line(data = list(xAxis = 12), title = "Speed Limit") %>% 
  e_mark_line(data = list(xAxis = 22), title = "Need for Speed") 
Run Code Online (Sandbox Code Playgroud)