jbkunst / jbkunst/d3wordcloud

Unexpected Behavior (overlap and not disappear)

Open
#27 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
R
Stars
63
Forks
15
PR merge metrics
No merged PRs in 30d

Description

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](https://user-images.githubusercontent.com/22753281/38953563-69ccf782-434f-11e8-867b-76138318ccbc.png)

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.