【问题标题】:How I can change the orient of labels on echarts4r?如何更改 echarts4r 上标签的方向?
【发布时间】:2022-01-23 04:34:17
【问题描述】:

您好,感谢您阅读本文。我正在尝试在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)
        ))

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

【问题讨论】:

    标签: r echarts4r


    【解决方案1】:

    您可以通过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)
            ))
    

    【讨论】:

    • 非常感谢,它有效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 2021-01-16
    • 2012-02-08
    • 1970-01-01
    相关资源
    最近更新 更多