Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading