0

Data with the date variablei'm creating a dashboard using the shiny package. One of the plots, which is supposed to show the date on hover is not doing so, instead, its displaying a decimal value for the date. Date is saved in the as.Date() function, in the 'date' variable :

custData$date <- as.Date(custData$date, "%m/%d/%Y") 

Server.R code for displaying the plot:

output$sidePlot2 <- renderPlotly({print(ggplotly(custData %>% group_by(date) %>% summarise(revenue = sum(lineTotal)) %>% ggplot(aes(x = date, y = revenue)) + geom_line() + geom_smooth(method = 'auto', se = FALSE) + labs(x = 'Date', y = 'Revenue (£)', title = 'Overall Revenue Trend by Date') ) ) } ) 

Plot with wrong date format on hover

2
  • 2
    May be the date conversion is not right, can you share reproduce your data? Commented Apr 2, 2018 at 8:29
  • Try downloading the newest version of ggplot2 with devtools::install_github("tidyverse/ggplot2"). I recently came across a similar issue and resolved it by upgrading from 2.2.1 (the CRAN version) to 2.2.1.9000 Commented Apr 2, 2018 at 20:18

1 Answer 1

1

I think you would need to define text inside aes of ggplot.

... %>% ggplot(aes(x = date, y = revenue, text = paste('Date: ', as.Date(date), '<br>Revenue: ', revenue))) + geom_line() + ... 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.