如何改变echarts4r标签的方向?

How I can change the orient of labels on echarts4r?

您好,感谢您阅读本文。我正在尝试在 echarts4r 上制作带有值标签的条形图,但我无法更改标签的方向以使值不重叠。我试过 orient = "vertical" 但它不起作用。我的代码如下:

library(echarts4r)
library(dplyr)

mtcars |> 
  tibble::rownames_to_column("model") |> 
  mutate(cyl2 = cyl*10000) |> 
  e_charts(model) |> 
  e_bar(cyl2,
        label = list(
          show = TRUE,
          position = "top",
          orient = "vertical",
          textStyle = list(fontFamily = "Roboto Condensed", 
                           fontSize = 12)
        ))

有没有办法改变标签的方向?感谢帮助

您可以通过 rotation 参数设置值标签的方向。根据您想要的结果,您还必须设置 verticalAlignment 和水平 alignment:

library(echarts4r)
library(dplyr)

mtcars |> 
  tibble::rownames_to_column("model") |> 
  mutate(cyl2 = cyl*10000) |> 
  e_charts(model) |> 
  e_bar(cyl2,
        label = list(
          show = TRUE,
          position = "top",
          rotate = 90,
          verticalAlign = "middle",
          align = "left",
          textStyle = list(fontFamily = "Roboto Condensed", 
                           fontSize = 12)
        ))