JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
595 stars 81 forks source link

e_axis does not work with dates: "Error: no attribute" (v0.4.4) #505

Closed awcm0n closed 1 year ago

awcm0n commented 1 year ago

Customizing a date axis with e_axis does not work: "Error: no attribute"

Here is a minimal example:

library(tidyverse)
library(echarts4r)

df <- tibble(date = c("3/9/2023", "3/10/2023", "3/11/2023"),
             y = c(1, 2, 3)) |>
  mutate(date = as.Date(date))

df |>
  e_charts(date) |>
  e_line(y) |>
  e_x_axis(date)
rdatasculptor commented 1 year ago

I am not sure why you put 'date' inside e_x_axis(), but when you remove it and add custumisations to the x axis then everything seems okay? If not, maybe you can explain what you intented in the first place?

this works:

df <- tibble(date = c("3/9/2023", "3/10/2023", "3/11/2023"),
             y = c(1, 2, 3)) |>
  mutate(date = as.Date(date))

df |>
  e_charts(date) |>
  e_line(y) |>
  e_x_axis(name = "this just works!", 
           nameLocation = "center", 
           nameTextStyle = list(fontWeight = "bold", 
                                fontSize = 15))

@awcm0n Did this help you out?

munoztd0 commented 1 year ago

Closing because of inactivity