ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
787 stars 208 forks source link

No plot in Rstudio, wordcloud2 #262

Open Lchiffon opened 7 years ago

Lchiffon commented 7 years ago

I've written a package called wordcloud2, it can be install by

install.packages("wordcloud2")

wordcloud2 function works well in Rstudio. However, when I use letterlcloudanother function to create wordcloud as a Letter, it cannot be ploted in Rstudio. Opening in browser or reload the viewer can solve this problem.

library(wordcloud2)
letterCloud(demoFreq,"R")

This bug appears in Windows, ubuntu as well as Mac....

I'm wondering if there's something wrong in htmlwidgets, Rstudio, or any way can I debug it.

yihui commented 7 years ago

On my computer, this only occurs once for a newly opened RStudio session. If you call letterCloud() again, you can see the wordcloud; even if you restart the R session, it still works. It seems to be specific to letterCloud(). Other widgets in other packages work fine. I have no idea about what is wrong here.

AdeelK93 commented 7 years ago

What a strange bug, I'm getting the same thing. Along with a js console error saying:

Uncaught TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The provided double value is non-finite. at maskInit (./wordcloud2-0.0.1/hover.js:113:19) at Object.renderValue (./wordcloud2-binding-0.2.0/wordcloud2.js:24:9) at ./htmlwidgets-0.8/htmlwidgets.js:625:19 at Array.forEach (native) at forEach (./htmlwidgets-0.8/htmlwidgets.js:55:14) at ./htmlwidgets-0.8/htmlwidgets.js:551:7 at Array.forEach (native) at forEach (./htmlwidgets-0.8/htmlwidgets.js:55:14) at Object.window.HTMLWidgets.staticRender (./htmlwidgets-0.8/htmlwidgets.js:549:5) at HTMLDocument. (./htmlwidgets-0.8/htmlwidgets.js:638:26)

Either way, I think this is more of a wordcloud2 issue than an htmlwidgets issue

Lchiffon commented 7 years ago

@AdeelK93

In my Rstudio, there's no error in the js console. And, I found this will happen to other packages:

threejs::globejs()

If I don't refresh the viewer, I cannot see the earth.

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936   
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                   
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

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

other attached packages:
[1] threejs_0.2.2

loaded via a namespace (and not attached):
 [1] htmlwidgets_0.8 Matrix_1.2-7.1  htmltools_0.3.6
 [4] tools_3.3.2     base64enc_0.1-3 yaml_2.1.14    
 [7] Rcpp_0.12.10    grid_3.3.2      jsonlite_1.4   
[10] digest_0.6.12   lattice_0.20-34
liangzhenghua commented 7 years ago

Happy to see yihui and Lchiffon, the author of wordcloud2!

I found this issue when I try to run the chinese character demo of wordcloud2. Disappointedly, I failed to generate a wordcloud of chinese character vectors, and had the same problem as mentioned above. Moreover, I found a strange bug that when I input several chinese characters through sougou typewriting, sometime it works sometimes not. I think this problem belongs to htmlwidgets.

The attribute of htmlwidget and wordcloud2 should be checked carefully.