You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shiny移动端无法通过ggplot选点生成表格问题求助

解决Shiny移动端无法生成刷选表格的问题

问题根源在于默认的brush配置未启用触摸支持,移动端的触摸操作无法触发刷选事件,导致brushedPoints无数据输出,表格无法生成。

修改方案

在plotOutput的brush参数中,使用brushOpts显式开启触摸支持:

ui <- fluidPage(
  plotOutput("plot", brush = brushOpts(id = "plot_brush", touch = TRUE)),
  tableOutput("data")
)
server <- function(input, output, session) {
  output$plot <- renderPlot({
    ggplot(mtcars, aes(wt, mpg)) + geom_point()
  }, res = 96)
  
  output$data <- renderTable({
    brushedPoints(mtcars, input$plot_brush)
  })
}

补充说明

  • touch = TRUE会让Shiny监听移动端的触摸刷选事件,与桌面端鼠标刷选行为保持一致。
  • 若需调整触摸刷选的响应延迟等细节,可在brushOpts中添加delay参数,例如brushOpts(id = "plot_brush", touch = TRUE, delay = 100)。

内容的提问来源于stack exchange,提问作者V A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 14:15:39