Here is my data
new <- structure(list(Var1 = structure(c(1L, 5L, 4L, 6L, 2L, 3L, 1L,
5L, 4L, 6L, 2L, 3L, 1L, 5L, 4L, 6L, 2L, 3L, 1L, 5L, 4L, 6L, 2L,
3L, 1L, 5L, 4L, 6L, 2L, 3L, 1L, 5L, 4L, 6L, 2L, 3L, 1L, 5L, 4L,
6L, 2L, 3L, 1L, 5L, 4L, 6L, 2L, 3L, 1L, 5L, 4L, 6L, 2L, 3L, 1L,
5L, 4L, 6L, 2L, 3L), .Label = c("Month of 2013-07", "Month of 2013-08",
"Month of 2013-09", "Month of 2013-10", "Month of 2013-11", "Month of 2013-12"
), class = "factor"), Var2 = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L,
8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L,
10L, 10L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Group 1", "Group 10",
"Group 2", "Group 3", "Group 4", "Group 5", "Group 6", "Group 7",
"Group 8", "Group 9"), class = "factor"), value = c(1, 0.073,
0.106, 0.056, 0.036, 0.007, 0, 1, 0.006, 0.022, 0.005, 0.038,
0, 0.867, 1, 0.052, 0, 0.147, 0, 0.005, 0.007, 1, 0.005, 0.003,
0, 1, 0.474, 0.017, 0, 0.039, 0.026, 0.001, 0.008, 0, 1, 0.01,
0.004, 0, 0.074, 0.001, 0.003, 1, 0, 0.006, 1, 0.003, 0.012,
0.011, 0, 0.911, 1, 0.352, 0, 0.27, 0, 0.349, 0.016, 0.101, 1,
0.845)), .Names = c("Var1", "Var2", "value"), row.names = c(NA,
-60L), class = "data.frame")
(this is the reproducible data for the chart)
Code to generate the chart:
require(rCharts)
inteplot.7 <- rPlot(Var1 ~ Var2, color = 'value', data = new ,type = 'tile')
inteplot.7$guides("{color: {scale: {type: gradient, lower: white, upper: steelblue}}}")
inteplot.7$guides(x = list(levels = c('Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5',
'Group 6', 'Group 7', 'Group 8', 'Group 9', 'Group 10')))
inteplot.7
Any idea why it is not showing in browser?
(edited) I am using Chrome. Does work in IE. Any solution to make it works in Chrome? (edited2) options for my markdown
```{r results = 'asis', comment = NA, cache = T,echo=F,fig.height=550,out.height=550,fig.width=1000,out.width=1000,message=FALSE,warning=FALSE}
options(rcharts.mode = 'iframe', rcharts.cdn = TRUE)
op <- options(gvis.plot.tag='chart')
inteplot.7$show('iframesrc', cdn = T,static = FALSE)
```
I too have experienced the problem you describe. I have found the following workaround, which also offers what I think is a better workflow.
r
chunk (instead of attempting to display it 'inline')<iframe>
I think this is better workflow because you can save all your documents' charts with meaningful names and have them at hand for insertion into other documents, should you need to. If your system does not compile a few months from now and a deadline is looming, you'll have the standalone html to go with.
Example:
```{r 'Figure_1_1', results = 'asis', comment = NA, cache = FALSE, fig.height = 5, fig.width = 8}
require(rCharts)
load("data/df_1_1.Rda")
# round data for rChart tooltip display
df_1_1$value <- round(df_1_1$value, 2)
n <- nPlot(value ~ Year, group = 'variable', data = df_1_1, type = 'lineChart')
n$save('figures/Figure_1_1.html', standalone = TRUE)
```
<iframe src ='figures/Figure_1_1.html', width = "860px", height = "450px"></iframe>
Note how I'm playing with the r chunk's fig.height
and fig.width
(in inches) and the html iframe's width
and height
(in pixels), to achieve both high resolution and a fit to the web page dimensions. I'm not sure what the fig.height
and fig.height
do to the rChart (if anything), but if you have other type of charts in your document, such as ggplot2
plots, then you will probably want to set figure dimensions in both r
and html
chunks.
If you get a conflict with fig.retina
(as I did as a result of setting out.width
in the r
chunk), then set it to NULL in the r chunk: fig.retina = NULL