I use ggplotly to show an interactive time series chart. The x axis is in the date format, but the tool tip of the hover in plotly converts the date format to a numerical value (screenshot attached). Any ideas on how to get the date to display as a suitable date in the tooltip?
The following is a short snippet of code:
output$ggplot <- renderPlotly({
plotbycity<-df_postgres %>% group_by(city, date, bedroooms) %>%
filter(city %in% input$checkGroup & bedroooms==input$radio) %>%
summarise(count=n(),rent=median(rent)) %>%
ungroup()
plotbycity$date<-as.Date(plotbycity$date)
plotbycity<-plotbycity[!is.na(plotbycity$city),]
if (is.null(plotbycity)) return(NULL)
gg <-ggplot(plotbycity, aes(x = date, y = rent, group = city, color = city,
text = paste('obs: ', count))) +
geom_line() +
ggtitle("Monthly Rents")
p <- ggplotly(gg, tooltip = c("x", "y", "text"))
p[![enter image description here][1]][1]
source
share