include an rCharts into a html repport
Opened this issue · 4 comments
any idea how to do this?
I was hoping it would be ok with
<%=
library(rCharts)
n1 <- nPlot(mpg ~ wt, data = mtcars, type = 'scatterChart')
n1$show('inline', include_assets = TRUE, cdn = TRUE)
%>
but no success, just blank with no error or messages
Thanks for any comments,
Cheers
oops! I probably have an install problem,
I'll reinstall the latest rCharts packages and try again ... after the we.
I'll keep you informed
Cheers
Well,
after some installations tricks (cf. ramnathv/rCharts#373 for details) , I came up with the following solution
...
<%
#----------------------------------------------------
# template function definition section
#----------------------------------------------------
save_stdout <- function(x){
paste(capture.output(x), collapse = '\n')
}
%>
...
<%=
require(rCharts);
a <- hPlot(Pulse ~ Height, data = MASS::survey, type = "bubble", title = "Zoom demo", subtitle = "bubble chart", size = "Age", group = "Exer");
save_stdout(a$show('inline', include_assets = TRUE, standalone = TRUE));
%>
Great to know that this works, rCharts
is indeed a great tool. Maybe we can include the save_stdout
in the package, if you wish.
yes, but we probably have to think about something more generic and be able to print html if we wish the plot to be dynamic ( only in an html reppport I guess, but the next questions will then be how to deal with dependencies -*.css, *.js - and local vs. web-server deployment) and a picture if we are ok to lose the dynamic part (e.g. pdf, doc, ....).
Maybe the default policy can just be if html then dynamic
( iframes are probably better to store charts with many data, and to prevent libraries conflict. For Iframe cf showMethod='iframe'
in the gfa.rcharts.save.wrapper
explained in #105) else then pictures
For the picture part, the only solution I found is explained in #105