Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add click event to wordcloud2Output() shiny function #35

Merged
merged 5 commits into from
Jun 19, 2018
Merged

add click event to wordcloud2Output() shiny function #35

merged 5 commits into from
Jun 19, 2018

Conversation

AdamSpannbauer
Copy link
Contributor

Added getClickedWord() function and the resulting functionality to renderWordcloud2.R.

  • This functionality adds a click event to the wordcloud2 widget in a shiny app.
  • The click event assigns the value of the hover information of the clicked word to input$outputId_clicked by default.
  • The name of the input id can be chosen by the user through the clickedWordInputId argument added to wordcloud2Output()
  • The implementation of the click event required shiny to be listed as an Import in DESCRIPTION

@AdamSpannbauer
Copy link
Contributor Author

AdamSpannbauer commented Jan 19, 2018

Here is a minimal app demoing the click event functionality.

devtools::install_github("AdamSpannbauer/wordcloud2")

library(shiny)
library(wordcloud2)
shinyApp(
  ui=shinyUI(fluidPage(
    #using default clicked word input id
    wordcloud2Output("my_wc"),
    #using custom clicked word input id
    wordcloud2Output("my_wc2", clickedWordInputId = "wc2_clicked_word"),

    verbatimTextOutput("print"),
    verbatimTextOutput("print2")
  )),
  server=shinyServer(function(input,output,session){
    output$my_wc  = renderWordcloud2(wordcloud2(demoFreq))
    output$my_wc2 = renderWordcloud2(wordcloud2(demoFreq))

    #using default clicked word input id
    output$print  = renderPrint(input$my_wc_clicked)
    #using custom clicked word input id
    output$print2 = renderPrint(input$wc2_clicked_word)
  })
)

@zschuster
Copy link

@Lchiffon I've implemented click events with the additions to the wordcloud2 package proposed by @AdamSpannbauer . It'd be great to have the PR approved.

@tedhwang
Copy link

Hey guys. I'm not sure if this is a right place to ask question but if so, would it be possible, under the current setting, to implement clicking a word which would open the new window at a designated link attached to the word? Basically I'd like it to be one click and go, not having to click separate hyperlink shown in Shiny again.

@AdamSpannbauer
Copy link
Contributor Author

@tedhwang as you mentioned, this isn't really the right place to ask questions like this. Pull Request threads are intended to be focused discussions concerning the PR itself.

StackOverflow is more geared towards questions like this. This SO Q/A covers the topic you're asking about. This gist uses the same JS function to directly cover your wordcloud2 use case. In the future keep SO in mind for these types of questions (even though you did get an answer this time).

@tedhwang
Copy link

tedhwang commented Jun 13, 2018 via email

@Lchiffon Lchiffon merged commit 97530b6 into Lchiffon:master Jun 19, 2018
@Lchiffon
Copy link
Owner

merged, thanks @AdamSpannbauer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants