Open Borye opened 9 years ago
I have the same issue.
@Borye : Does your n1.html file start like this?
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//dimplejs.org/dist/dimple.v2.1.0.min.js' type='text/javascript'></script>
I'm having the same problem trying to save my dimple plot too, although I can see it in RStudio.
dP$save('plot.html', cdn = TRUE)
but it seems that the html file is not being generated in a proper way. Those lines should be
...
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script>
...
Does anybody have the same problem? Here the information of my session:
> options(width = 120)
> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------------------
setting value
version R version 3.2.0 (2015-04-16)
system x86_64, linux-gnu
ui RStudio (0.98.1103)
language en_US
collate en_US.UTF-8
tz <NA>
Packages ---------------------------------------------------------------------------------------------------------------
package * version date source
devtools * 1.7.0 2015-01-17 CRAN (R 3.2.0
)
digest * 0.6.8 2014-12-31 CRAN (R 3.2.0)
formatR * 1.2 2015-04-21 CRAN (R 3.2.0)
highr * 0.5 2015-04-21 CRAN (R 3.2.0)
htmltools * 0.2.6 2014-09-08 CRAN (R 3.2.0)
knitr 1.10.5 2015-05-06 CRAN (R 3.2.0)
lattice * 0.20-31 2015-03-30 CRAN (R 3.1.3)
magrittr * 1.5 2014-11-22 CRAN (R 3.2.0)
plyr * 1.8.2 2015-04-21 CRAN (R 3.2.0)
rCharts 0.4.5 2015-05-09 Github (ramnathv/rCharts@389e214)
Rcpp * 0.11.6 2015-05-01 CRAN (R 3.2.0)
rjson * 0.2.15 2014-11-03 CRAN (R 3.2.0)
RJSONIO * 1.3-0 2014-07-28 CRAN (R 3.2.0)
rmarkdown * 0.6.1 2015-05-07 CRAN (R 3.2.0)
rstudio * 0.98.1103 2015-05-08 local
rstudioapi * 0.3.1 2015-04-07 CRAN (R 3.2.0)
stringi * 0.4-1 2014-12-14 CRAN (R 3.2.0)
stringr * 1.0.0 2015-04-30 CRAN (R 3.2.0)
whisker * 0.3-2 2013-04-28 CRAN (R 3.2.0)
yaml * 2.1.13 2014-06-12 CRAN (R 3.2.0)
Mine has this:
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script>
<script src='//nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script>
Even when I manually fix the links, I still cannot view the graph in my html file.
This is a known issue https://github.com/ramnathv/rCharts/issues/497 for RStudio Viewer + Windows + nvd3. If you open in a browser, you should see it as expected.
Never mind, it appears RStudio now tries to serve the page, so I think all rCharts
will not show up correctly unless you do
n1$show(cdn=T)
On a separate note, nPlot
seems to show up fine now in RStudio Viewer, so you should be able to remove the options(viewer = NULL)
.
n1$show(cdn=t)
doesnt'work in Rstudio Viewer, not even when I used options(viewer=NULL)
and it does not work in shinydashboard neither but it worked on other computer....
I've posted about that here:
http://stackoverflow.com/questions/30213917/multibarchart-nvd3-in-rcharts-is-not-displaying
When you save html like this:
n1$save('n1-cdn.html', cdn=TRUE)
n1$save('n1-nocdn.html', cdn=FALSE)
The saved with cdn=FALSE
looks like to open in web-browser but the one with TRUE
does not open. But how to use cdn=FALSE
in shinyapp?
Incidentally, this works for me in both browser and Rstudio.
https://gist.github.com/ramnathv/5531732
Seems like a better working example to point people to.
The issue seems to the header f the html file, if you save it using cdn = TRUE
, then the header looks something like this:
...
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//dimplejs.org/dist/dimple.v2.1.0.min.js' type='text/javascript'></script>
...
if you save it using cdn = FALSE
it will link to your folder locally, so something like this
<script src='C:/Users/[user]/Documents/R/win-library/3.2/rCharts/libraries/
If you edit the header and set it to
...
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"></script>
...
then everything works fine.
If think the solution is to copy these libraries to your local folder, or somehow set the yaml to give the proper src. The question then is, does anyone know how to set the yaml properly?
It might be imposible in shiny app (exactly in shinydahboard). Problem wasn't visible when I run this code on Windows. The problem of not displaying was under ubuntu.
Hi, I ended up modifying the html output plot as follows:
# Save plot
dP$save(paste0(output, '.html'), cdn = TRUE)
# Open html file
html <- readLines(paste0(output, '.html'))
# Identify lines where libraries are used
d3 <- grep(".*/d3.*\\.js.*", html, perl = TRUE)
dimple <- grep(".*/dimple.*\\.js.*", html, perl = TRUE)
# Substitute with web-based libraries
html[d3] <- '<script src="http://d3js.org/d3.v3.min.js"> type="text/javascript"></script>'
html[dimple] <- '<script src="http://dimplejs.org/dist/dimple.v2.1.2.min.js"> type="text/javascript"></script>'
# Save new html plot
con <- file(paste0(output, '_fixed.html'))
writeLines(html, con)
close(con)
It's kind of dirty, but at least now is reproducible. Hope this can be helpful to someone.
I am also having this problem. When I run
hair_eye_male <- subset(as.data.frame(HairEyeColor), Sex == "Male")
n1 <- nPlot(Freq ~ Hair, group = "Eye", data = hair_eye_male, type = "multiBarChart")
n1$print("chart3")
I don't get any visual output in RStudio. I am using RStudio version 0.98.1103, and just got the most recent version of rCharts a few minutes ago. Using Ubuntu 14.04...hummm....
Hi, I am trying your example code. But I can't get anything in both Rstudio or browser. The code is:
The reason I add
options(viewer = NULL)
is because I found a post which said this command can show the plot directly on browser. And it works fine on others computer. But in my laptop it shows nothing. I have tried to browse the n1.html directly from my folder, but still nothing cames up.My
sessionInfo()
is as below:Please help me with this. It killing me right now. Thank you.