how to customize plotly annotation

I am trying to build an app where I want to create a plotly dodged bar graph. I am trying to give you a reprex.


# load_libraries -------------------------------------------------------

library(plotly)
library(data.table)
library(lubridate)


# set Default -------------------------------------------------------------
setDTthreads(4)


# create Data -------------------------------------------------------------

year <- c(
          ymd(paste(rep(2017,12),1:12,1,sep = "-")),
          ymd(paste(rep(2018,12),1:12,1,sep = "-"))
)

dt <- data.table(year = sample(year,240,TRUE),
           variable = sample(letters[1:3], 240, TRUE),
           value = ceiling(rnorm(240,100,20))
)


# plot --------------------------------------------------------------------

dt %>% 
  plot_ly(x = ~year,
          y = ~value,
          color = ~variable) %>% 
  add_bars() %>% 
  add_annotations(text = ~value,
                  showarrow = FALSE) %>% 
  layout(barmode = 'dodge')

  1. When you draw this plot you will see that xaxis label are automatically being picked. You can't controll if you actually want to hide them or not.

  2. annotation doesn't go on top of each bar.

Please if anybody can tell me how to control xaxis and annotation. Remeber it's a dynamic graph on shiny dashboard so I can't use any hardcoded logic.