简体   繁体   中英

How I can change the orient of labels on echarts4r?

Hi and thanks for reading this. I am trying to make a bar plot with value labels on echarts4r , but I can't change the orientation of the labels so that the values do not overlap. I tried orient = "vertical" but it doesn't work. My code is as follows:

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)
        ))

Is there a way to change the orientation of the labels? Thanks for the help

You could set the orientation of the value labels via the rotation parameter. Depending on your desired result you also have to set the verticalAlignment and the horizontal align ment:

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)
        ))

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM