Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the axis labels get hidden when I use e_x_axis(axisLabel = list(inside = TRUE)). #447

Closed
Essossinam opened this issue Jul 27, 2022 · 3 comments

Comments

@Essossinam
Copy link

Hello,

I am trying to produce a bar chart where the x-axis labels face the inside direction; that is I want the axis labels to be visible on the inside bottom of the bars. Although specifying e_x_axis(axisLabel = list(inside = TRUE)) in the code renders that effect, the labels get hidden by the bars (as shown in the image below). I am struggling to make the labels come out properly.

Below are the code and the resulting graph.

Any idea?

library(echarts4r)
library(dplyr)

country <-  c("Côte d'Ivoire", "Papua New Guinea", "Republic of Venezuela", "The United Kingdom ", "South Africa")
quantity <- c(2000, 500, 1800,  2500, 18000)

df <- data.frame(country, quantity)

df %>% 
  e_charts(country) %>%
  e_bar(quantity,
         label = list(show = TRUE, 
                      position = "insideEnd", 
                      offset = c(535, 17)),
        showBackground = TRUE,
        itemStyle = list(color = "#490B3D")
  ) %>%
  e_x_axis(
    axisTick = list(show = FALSE),
    axisLine =list(show = FALSE),
    axisLabel = list(show = TRUE, inside = TRUE),
    inverse =  TRUE
  ) %>% 
  e_y_axis(show = FALSE) %>% 
  e_flip_coords() %>% 
  e_legend(show = FALSE)

image

@rdatasculptor
Copy link
Contributor

@Essossinam I would suggest: Try playing with the z and with the text color (for a proper contrast). At least the labels are shown now:

library(echarts4r)
library(dplyr)

country <-  c("Côte d'Ivoire", "Papua New Guinea", "Republic of Venezuela", "The United Kingdom ", "South Africa")
quantity <- c(2000, 500, 1800,  2500, 18000)

df <- data.frame(country, quantity)

df %>% 
  e_charts(country) %>%
  e_bar(quantity,
         label = list(show = TRUE, 
                      position = "insideEnd", 
                      offset = c(535, 17)),
        showBackground = TRUE,
        itemStyle = list(color = "#490B3D"),
        z = 1
  ) %>%
  e_x_axis(
    axisTick = list(show = FALSE),
    axisLine =list(show = FALSE),
    axisLabel = list(show = TRUE, inside = TRUE),
    inverse =  TRUE,
    z = 2
  ) %>% 
  e_y_axis(show = FALSE) %>% 
  e_flip_coords() %>% 
  e_legend(show = FALSE)     

@Essossinam
Copy link
Author

@rdatasculptor Thanks a lot. It works.

@rdatasculptor
Copy link
Contributor

I think you can close the issue now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants