Search code examples
rplotlineecharts

Remove timestamp and display full date in x axis, echarts4R


data_ <- data.frame(
  x = c(7, 20, 12, 15),
  y = as.Date(c('2019-01-28', '2019-01-29', '2019-01-30', '2019-01-31'))
)

data_ %>%
  e_charts(y) %>%
  e_line(x)

In the above plot timestamps between dates are appearing. How can I remove the timestamp and show full date in x axis?


Solution

  • Change the type of the x-axis to category.

    data_ %>%
      e_charts(y) %>%
      e_line(x) %>%
      e_x_axis(type='category')
    

    enter image description here