Open ThoDuyNguyen opened 9 years ago
I am not sure I can help a whole lot here, since I have no experience with Shiny Server. One thought, but I doubt it will help. Can you add draw = FALSE
to treemap()
?
This Stack Overflow post appears related. Specifying a aspRatio
for treemap
seems to be the solution based on my reading of the answers, since there is no way to specify height
and width
in treemap
. Also, there is this Google Groups-shiny but there is no answer or resolution there.
Maybe some background information might help also. d3treeR
uses treemap
to create the tree structure, and due to the way treemap
is designed treemap
must draw a plot. So a R graphics device is required, and it seems in your example R
/Shiny server is choosing a default pdf
graphics device.
Sorry to fumble around. Let me know if any of the above works.
I will get the feedback as soons as I back to my server.
Kind regards
@timelyportfolio: I update the new code, if I put draw = FALSE as parameter of treeMap(), there was "unused parameter".
So i use the original code (also test with all d3Tree render methods)
session_info in Shiny Server
list(
version = "R version 3.2.1 (2015-06-18)", system = "x86_64, linux-gnu", ui = "X11", language = "(EN)", collate = "en_US.UTF-8", tz = NA
) list(
package = c(
"assertthat", "chron", "colorspace", "curl", "d3treeR", "data.table", "data.tree", "DBI", "devtools", "digest", "dplyr", "DT", "ggplot2", "git2r", "gnm", "gridBase", "gridSVG", "gtable", "htmltools", "htmlwidgets", "httpuv", "igraph", "jsonlite", "lattice", "lazyeval", "lmtest", "magrittr", "MASS", "Matrix", "memoise", "mime", "munsell", "nnet", "parsetR", "plyr", "proto", "qvcalc", "R6", "RColorBrewer", "Rcpp", "relimp", "reshape2", "RJSONIO", "RPostgreSQL", "rversions", "scales", "shiny", "stringi", "stringr", "treemap", "vcd", "vcdExtra", "XML", "xml2", "xtable", "yaml", "zoo"
), `*` = c(
"", "", "", "", "*", "", "", "*", "*", "", "*", "*", "", "", "*", "", "", "", "", "*", "", "", "", "", "", "", "", "", "", "", "", "", "", "*", "", "", "", "", "", "", "", "", "", "*", "", "", "*", "", "", "*", "*", "*", "", "", "", "", ""
), version = c(
"0.1", "2.3-47", "1.2-6", "0.9.1", "0.1", "1.9.6", "0.2.2", "0.3.1", "1.8.0", "0.6.8", "0.4.3", "0.1", "1.0.1", "0.10.1", "1.0-8", "0.4-7", "1.4-3", "0.1.2", "0.2.6", "0.5", "1.3.3", "1.0.1", "0.9.17", "0.20-31", "0.1.10", "0.9-34", "1.5", "7.3-40", "1.2-1", "0.2.1", "0.4", "0.4.2", "7.3-9", "0.0.1", "1.8.3", "0.3-10", "0.8-9", "2.1.1", "1.1-2", "0.12.1", "1.0-4", "1.4.1", "1.3-0", "0.4", "1.0.2", "0.3.0", "0.12.2", "0.5-5", "1.0.0", "2.3", "1.4-1", "0.6-11", "3.98-1.3", "0.1.1", "1.7-4", "2.1.13", "1.7-12"
), date = c(
"2013-12-06", "2015-06-24", "2015-03-11", "2015-07-04", "2015-10-11", "2015-09-19", "2015-10-11", "2014-09-24", "2015-05-09", "2014-12-31", "2015-09-01", "2015-06-09", "2015-03-17", "2015-05-07", "2015-04-22", "2014-02-24", "2015-01-27", "2012-12-05", "2014-09-08", "2015-06-21", "2015-08-04", "2015-06-26", "2015-09-06", "2015-03-30", "2015-01-02", "2015-06-06", "2014-11-22", "2015-03-21", "2015-06-01", "2014-04-22", "2015-09-03", "2013-07-11", "2015-02-11", "2015-10-11", "2015-06-12", "2012-12-22", "2015-02-03", "2015-08-19", "2014-12-07", "2015-09-10", "2015-02-03", "2014-12-06", "2014-07-28", "2013-03-27", "2015-07-13", "2015-08-25", "2015-08-05", "2015-06-29", "2015-04-30", "2015-06-26", "2015-07-08", "2015-09-17", "2015-06-30", "2015-06-02", "2014-09-12", "2014-06-12", "2015-03-16"
), source = c(
"CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "Github (timelyportfolio/d3treeR@8ad4ed3)", "CRAN (R 3.2.1)", "Github (gluc/data.tree@18b31b0)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "Github (timelyportfolio/parsetR@8cd92d0)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.2.1)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)", "CRAN (R 3.1.3)"
)
)
I also notice that if a level has more than 6 values then the parset only has 6 colors and use black for the rest of values. As we are recommended not to use more than 6 color/shape in a chart so I don't think it's a bug but it would be nice if the parset support more color for more than 6 values of a level.
Kind regards
The parameter draw=FALSE
requires the Github version of treemap
. One possibly better way to handle this might be to create the treemap
separately with code something like this.
output$d3Tree <- renderD3tree2({
tf <- tempfile()
png(tf, height = 400, width=600) #you'll need to be specific with height and width
tm <- treemap(
groupData(),
index = c("location", "level"),
vSize = "amount",
vColor = "amount",
type = "value"
)
dev.off()
d3tree2(tm,rootname = "lohoi")
})
I'll start a separate issue with parsetR to handle more than 6 levels.
Thanks.
I'll let you know when I have the result.
Any answer? I'm getting the same "cannot open file 'Rplots.pdf'" error only on shiny server, but it's not using this package. I'm assuming it's a similar cause though
I was getting this error too and it was indeed fixed by finding a folder on the server that I definitely had permission to write to and running:
output$treeMapPlot <- renderD3tree2({
data(GNI2010)
tf <- "/my_temp_file_location"
png(tf, height = 400, width=600) #you'll need to be specific with height and width
tm <- treemap(
GNI2010,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value",
draw = FALSE
)
dev.off()
d3tree2( tm,rootname = "World" )
})
It would be nice though if there were a way to run treemap without generating an output that has to be saved to a temporary location. Thank you though! We are really happy to use this!
I am having the same issue with renderValueBox and renderDygraph. Solved it just adding
pdf(NULL)
as suggested in https://github.com/ropensci/plotly/issues/494
I used chown -R shiny:shiny /srv/shiny-server as https://github.com/ropensci/plotly/issues/494 suggests!
I had a similar problem with the treemap in flexdashboard. It was drawing the d3treemap under the regular, static treemap. Fixed with the pdf(NULL) recommended by @fersa.
I know this is an old topic, but I ran into the same issue with an app that was using a ui/server/global setup. The error may be that a plot or similar object created in the global script can't be used by the app do to issues with permissions.
In my case, I had created some functions in the global file that the app would use to generate new plots based on user inputs. To have something showing when the app first loads, I had run the plot generating functions in global with sample data. All I had to do is move the initial plot function runs from the global to the server script, and everything worked.
ui.R:
server.R:
The app runs fine on RStudio.
But when I deployed on Shiny server, it raised an error: Log on shiny server:
Therefore, the tab which contains d3tree2Output could not render the plot with message:
The others tabs (DT and parsetR) were rendered correctly (though parsetR had problem stated here: https://github.com/timelyportfolio/parsetR/issues/2) R on the server is 3.2.1, all the packages using in the example are up to date.
Please let me know how to fix it.
Kind ragards