为什么我的悬停不起作用?当我将鼠标悬停在上面时,会出现不同的光标(黑色十字)但我没有收到信息。这是在以前的版本中工作,从那时起我没有改变我的hoverOpts部分,但现在由于某种原因它没有工作。由于保密原因,我无法提供我担心的数据,但这是我的代码:
library(ggplot2)
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
titlePanel("Transfers Analysis App"),
sidebarLayout(
sidebarPanel(
useShinyjs(),
id="form",
pickerInput(inputId = "Day",
label = "Days of Week",
choices = c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"), selected = data$day[data$day %in% c('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')],
options = list(`actions-box` = TRUE),
multiple = T
),
pickerInput(inputId = "Month",
label = "Months",
choices = c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"), selected = data$month[data$month %in% c('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')],
options = list(`actions-box` = TRUE),
multiple = T
),
radioButtons("Curves", "Curve",
choices = c("None", "Total", "Outages", "Days After an Outage"),
selected = "None"
),
checkboxInput("Outage", "Show Outages", FALSE),
checkboxInput("DayAfter", "Show Day After Outages", FALSE),
actionButton("Reset", "Reset")
),
mainPanel(
plotOutput("plot1", height = "600px", width = "100%",
hover = hoverOpts(id = "plot_hover"),
verbatimTextOutput("hover_info")
)
)
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
Day <- input$Day
Month <- input$Month
Outage <- input$Outage
DayAfter <- input$DayAfter
Curves <- input$Curves
data <- data[data$day %in% input$Day]
data <- data[data$month %in% input$Month]
Reset <- input$Reset
g <- ggplot(data, aes(Date, NUMBER_OF_TRANSFERS), xlab=("Call Transfers")) + geom_point() + labs(y = "Call Transfers")
if (Curves == "Total")
g <- g + geom_smooth(colour="black") +
scale_colour_manual(values="black")
if (Curves == "Outages")
g <- g + geom_smooth(data=(data[Outage == "Outage"]), aes(color = (Outage[Outage == "Outage"]))) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), values=c( "red", "blue"), name = "Legend") +
theme(legend.position="bottom")
if (Curves == "Days After an Outage")
g <- g + geom_smooth(data=(data[DayAfter == "Day After an Outage"]), aes(color = (DayAfter[DayAfter == "Day After an Outage"]))) +
scale_colour_manual(values=c( "blue"), name= "Legend") +
theme(legend.position="bottom")
if ((Outage == TRUE) & (DayAfter == FALSE))
g <- g + geom_point(aes(color = Outage)) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), name= "Legend", values=c( "black", "red", "blue")) +
theme(legend.position="bottom")
if ((Outage == FALSE) & (DayAfter == TRUE))
g <- g + geom_point(aes(color = DayAfter)) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), name= "Legend", values=c("black", "blue", "red")) +
theme(legend.position="bottom")
if ((Outage == TRUE) & (DayAfter == TRUE))
g <- g + geom_point(aes(color = DayAfter2)) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), name= "Legend", values=c("purple", "blue", "black", "red")) +
theme(legend.position="bottom")
if ((Outage == TRUE) & (DayAfter == FALSE) & (Curves == "Days After an Outage"))
g <- g + geom_point(aes(color = Outage)) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), name= "Legend", values=c( "blue", "black", "red")) +
theme(legend.position="bottom")
if ((Outage == TRUE) & (DayAfter == TRUE) & (Curves == "Days After an Outage"))
g <- g + geom_point(aes(color = DayAfter2)) +
scale_colour_manual(breaks = c("Outage", "No Outage", "Day After an Outage", "Both"), name= "Legend", values=c( "purple", "blue", "black", "red")) +
theme(legend.position="bottom")
plot(g)
})
observeEvent(
input$Reset,
{
reset("form")
}
)
}
shinyApp(ui, server)