Wordcloud2 - 单击事件和鼠标指针

问题描述

我最近 asked a question,而是可以将鼠标更改为指针,当鼠标悬停在 Shinyapp 中 wordcloud 中的单词上时。答案成功。

library(shiny)
library(wordcloud2)
# Global variables can go here
n <- 1

# Define the UI
ui <- bootstrapPage(
  tags$head(tags$style(HTML('.wcLabel {cursor: pointer; pointer-events: auto !important;}'))),numericInput('size','Size of wordcloud',n),wordcloud2Output('wordcloud2'),)

# Define the server code
server <- function(input,output) {
  
  output$wordcloud2 <- renderWordcloud2({
    # wordcloud2(demoFreqC,size=input$size)
    wordcloud2(demoFreq,size=input$size)
  })
}

# Return a Shiny app object
shinyApp(ui = ui,server = server)

但现在,input$Wordcloud_clicked_word 不会再有反应了。

(编辑:正如 HubertL 正确提到的,在 CRAN 包中使用 click 事件是不可能的。但是,安装 GitHub 版本使其成为可能as noted here。 所以需要 devtools::install_github("lchiffon/wordcloud2") 才能使点击事件成为可能)

library(shiny)
library(wordcloud2)
# Global variables can go here
n <- 1

# Define the UI
ui <- bootstrapPage(
  tags$head(tags$style(HTML('.wcLabel {cursor: pointer; pointer-events: auto !important;}'))),verbatimtextoutput("ClickedWord")
)

# Define the server code
server <- function(input,size=input$size)
  })
  
  output$ClickedWord <- renderText(input$wordcloud2_clicked_word)
  
}

# Return a Shiny app object
shinyApp(ui = ui,server = server)

当我更改 .wcLabel 时,verbatimtextoutput 将不再在点击云中的单词时做出反应。

是否可以同时拥有,鼠标在悬停时变为指针并在点击单词时做出反应?

谢谢!

弗雷德里克

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)