【发布时间】:2021-08-19 19:07:28
【问题描述】:
这可能不是一个非常高级的问题,这里肯定有答案,但我真的无法在任何地方找到答案。
基本上,单击图块后,我希望将信息显示在图下方的框中。也就是说,我不想要现在显示的 x 和 y 坐标,我想要悬停在图块上时获得的信息 - 单击右上角的图块应该显示信息:“65”、“Toyota Corolla ", "33.9"。
为丑陋的例子道歉。
library(shiny)
library(dplyr)
test <- data.frame(rownames(mtcars),mtcars$mpg,mtcars$hp)
ui <- fluidPage(
plotlyOutput("bars"),
verbatimTextOutput("click")
)
server <- function(input, output, session) {
output$bars <- renderPlotly({
ggplot(data = test, aes(x = rownames.mtcars., y = mtcars.mpg)) +
geom_tile(aes(fill = mtcars.hp))
})
output$click <- renderPrint({
d <- event_data("plotly_click")
d
})
}
shinyApp(ui, server)
【问题讨论】: