score:1

Accepted answer

Highcharter likes a timestamp when you use dates like this. Try using the datetime_to_timestamp function as below and include text in your list along with point.

library(highcharter)

df <- data.frame(
  x = seq(as.Date("2021-01-01"),as.Date("2021-01-10"),by = "days"),
  y = 1:10
)

hchart(df, "line", hcaes(x = x, y = y))  %>%
  hc_annotations(
    list(
      labels = lapply(1:nrow(df),function(i){
        list(
          point = list(
            x = datetime_to_timestamp(df$x[i]),
            y = df$y[i],
            xAxis = 0,
            yAxis = 0
            ),
          text = as.character(df$y[i])
          )
      })
    )
  )

Related Query

More Query from same tag