Coder Social home page Coder Social logo

Comments (10)

gaospecial avatar gaospecial commented on August 30, 2024 6

Hi @samuelhuerga,

I found a way to slove my problem.

Just install my fork by devtools::install_github("gaospecial/wordcloud2"), and then it works.

The following test code

library(wordcloud2)
wordcloud2(data = head(demoFreq,3))
wordcloud2(head(demoFreq,3), color = "random-light", backgroundColor = "grey")
wordcloud2(head(demoFreq,6), color = "random-light", backgroundColor = "white")

will give the result:

image

I don't know why it works, as I just update the wordcloud2.js library to the latest version.

May this can be helpful.

from wordcloud2.

jrtran avatar jrtran commented on August 30, 2024 1

Thanks Gao! I found that your solution (using your fork) worked for me in a 'standard' RMarkdown document, but not when used with tabset within flexdashboard. Here's a repo I quickly created producing the example:

https://github.com/martinctc/wordcloud2-test

Any idea if this is more an issue with flexdashboard perhaps?

A bit old, but for @martinctc: something that got all of the wordclouds to show up for me was appending {.active} after each sub-header (e.g., ### Tab 1 {.active}.

Tab 1
Tab 2

from wordcloud2.

samuelhuerga avatar samuelhuerga commented on August 30, 2024

Happens the same here.

If I use two wordclouds in an rmd knitted to HTML, only the first one is shown.

from wordcloud2.

gaospecial avatar gaospecial commented on August 30, 2024

Happens the same here.

If I use two wordclouds in an rmd knitted to HTML, only the first one is shown.

Same here.

from wordcloud2.

gaospecial avatar gaospecial commented on August 30, 2024

here I have a alternative solution.

Use the following function.

#' Webshot a widget and place it in place with markdown syntax
#'
#' @param widget a html widget, i.e. generated by wordcloud2 pacakge
#' @param path figure webshot storage place
#'
#' @return
#' @export
#'
#' @examples
markdown_widget <- function(widget,path=getwd(),filename="file.png"){
  require(htmlwidgets)
  require(webshot)
  saveWidget(widget,"tmp.html",selfcontained = F)
  file <- paste(path,filename,sep = "/")
  webshot("tmp.html",file,delay = 5,vwidth = 1024,vheight = 768)
  file.remove("tmp.html")
  paste0("![",file,"](",file,")\n\n") %>% cat()
}

when in markdown file, insert a chunk like this:

```{r results="asis"}
widget <- wordcloud2(...)
markdown_widget(widget,path=".",filename="wordcloud.png")
```

then in your markdown file, the figure will finally show up.

from wordcloud2.

martinctc avatar martinctc commented on August 30, 2024

Thanks Gao! I found that your solution (using your fork) worked for me in a 'standard' RMarkdown document, but not when used with tabset within flexdashboard. Here's a repo I quickly created producing the example:

https://github.com/martinctc/wordcloud2-test

Any idea if this is more an issue with flexdashboard perhaps?

from wordcloud2.

daczarne avatar daczarne commented on August 30, 2024

I just used @gaospecial 's version and it rendered both my wordcloud2s while using flexdashboard. Belows my session information

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /opt/R/3.6.3/lib/R/lib/libRblas.so
LAPACK: /opt/R/3.6.3/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.0.2       data.table_1.13.0 dtplyr_1.0.1      magrittr_1.5      lubridate_1.7.9  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5          here_0.1            tidyr_1.1.0         prettyunits_1.1.1   ps_1.3.4            assertthat_0.2.1    rprojroot_1.3-2    
 [8] digest_0.6.25       packrat_0.5.0       R6_2.4.1            backports_1.1.8     evaluate_0.14       httr_1.4.1          ggplot2_3.3.2      
[15] pillar_1.4.6        rlang_0.4.7         lazyeval_0.2.2      curl_4.3            rstudioapi_0.11     callr_3.4.3         rmarkdown_2.3      
[22] desc_1.2.0          devtools_2.3.1      flexdashboard_0.5.2 readr_1.3.1         stringr_1.4.0       htmlwidgets_1.5.1   munsell_0.5.0      
[29] compiler_3.6.3      xfun_0.16           pkgconfig_2.0.3     pkgbuild_1.1.0      htmltools_0.5.0     tidyselect_1.1.0    tibble_3.0.3       
[36] fansi_0.4.1         viridisLite_0.3.0   crayon_1.3.4        withr_2.2.0         grid_3.6.3          jsonlite_1.7.0      formattable_0.2.0.1
[43] gtable_0.3.0        lifecycle_0.2.0     scales_1.1.1        cli_2.0.2           stringi_1.4.6       fs_1.5.0            remotes_2.2.0      
[50] testthat_2.3.2      ellipsis_0.3.1      generics_0.0.2      vctrs_0.3.2         forcats_0.5.0       tools_3.6.3         glue_1.4.1         
[57] purrr_0.3.4         hms_0.5.3           crosstalk_1.1.0.1   processx_3.4.3      pkgload_1.1.0       yaml_2.2.1          colorspace_1.4-1   
[64] sessioninfo_1.1.1   memoise_1.1.0       plotly_4.9.2.1      wordcloud2_0.2.3    knitr_1.29          usethis_1.6.1

from wordcloud2.

davidika avatar davidika commented on August 30, 2024

thank you @gaospecial !

I wonder what is causing the issue. Outdated package installing via "wordcloud2" directly?

from wordcloud2.

eimennin avatar eimennin commented on August 30, 2024

Thanks, @gaospecial I have had this problem for years!

Does anyone know why lettercloud() doesn't work?

from wordcloud2.

gaospecial avatar gaospecial commented on August 30, 2024

thank you @gaospecial !

I wonder what is causing the issue. Outdated package installing via "wordcloud2" directly?

May be the backend wordcloud javascript has bug, as its version is very low.

from wordcloud2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.