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

Unexpected Behavior (overlap and not disappear) #27

Open
systats opened this issue Apr 18, 2018 · 4 comments
Open

Unexpected Behavior (overlap and not disappear) #27

systats opened this issue Apr 18, 2018 · 4 comments

Comments

@systats
Copy link

systats commented Apr 18, 2018

Hi Joshua: thanks for your great community effort!

The problem in my application is that if the number of words is decreased, the words does not disappear but overlay with the existing ones. This looks like:

screenshot 2018-04-18 21 20 43

A minimal example:

#devtools::install_github("jbkunst/d3wordcloud")
library(shiny)
library(d3wordcloud)
library(dplyr)

### demo data
df <- tibble(
  word = c("#btc", "#Bitcoin", "#BTC", "#Airdrop", 
    "#bitcoin", "#blockchain", "#cryptocurrency", "#eth", "#cr", 
    "#crypto", "#Cryptocurrency", "#dgb", "#digibyte", "#Digitize", 
    "#Eth", "#Ethereum", "#ico", "#ICO", "#LTC", "#usd"), 
  n = c(10L, 5L, 5L, 4L, 4L, 4L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L)
)

ui <- fluidPage(
   titlePanel("Beautiful Wordcloud with Bug"),
   sidebarLayout(
      sidebarPanel(
        sliderInput(inputId = "n_cloud", label = "", min = 5, max = 20, value = 10)
      ),
      mainPanel(
        d3wordcloud::d3wordcloudOutput("wordcloud")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
   
  toks <- reactive({
    toks <- df %>%
      dplyr::slice(1:as.numeric(input$n_cloud)) %>%
      dplyr::arrange(dplyr::desc(n))
  })
  
  output$wordcloud <- d3wordcloud::renderD3wordcloud({
    d3wordcloud(toks()$word, toks()$n, padding = 4, rotate.min = 0, rotate.max = 45, font = "Impact")
  })
}

shinyApp(ui = ui, server = server)

This bug reproduced on Mac, Windows and Shiny Server. Thanks for your effort! Best, Simon

@jbkunst
Copy link
Owner

jbkunst commented Apr 18, 2018

Hi @systats !

Can you try without the the hashtag symbol?

@jbkunst
Copy link
Owner

jbkunst commented Apr 18, 2018

Sorry, I will not run the reprex yet :P, I think is due the # symbol is reserved in the html world 😅

@systats
Copy link
Author

systats commented Apr 18, 2018

df <- tibble(
  word = c("#btc", "#Bitcoin", "#BTC", "#Airdrop", 
    "#bitcoin", "#blockchain", "#cryptocurrency", "#eth", "#cr", 
    "#crypto", "#Cryptocurrency", "#dgb", "#digibyte", "#Digitize", 
    "#Eth", "#Ethereum", "#ico", "#ICO", "#LTC", "#usd"), 
  n = c(10L, 5L, 5L, 4L, 4L, 4L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L)
) %>% mutate(word = stringr::str_replace(word, "#", ""))

Well, good idea, but it does change neither the overlapping nor persistence of words. Do you get the same output? Thanks for the quick response!

@systats systats changed the title Strange Behavior Strange Behavior (overlap and not disappear) Apr 18, 2018
@systats systats changed the title Strange Behavior (overlap and not disappear) Unexpected Behavior (overlap and not disappear) Apr 18, 2018
@massimoaria
Copy link

Hi,
I have the same issue.
When I change an input, the new word cloud overlap the previous one. So, after few changes, the plot became unreadable

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

No branches or pull requests

3 participants