r - rChart forceY multiBar "Bar start" not correct in rmarkdown -
when run r code in console, output expected, when run in rmarkdown result:
the complete rmarkdown minimum example looks this: --- title: "untitled" author: "sda" output: html_document --- ```{r} library(dplyr) library(tidyr) library(rcharts) library(data.table) ``` ```{r results = 'asis', comment = f, message = f, tidy = f, echo=f, cache=f} mydata <- data.table(xaxis = rep(seq(0,length.out = 3),each = 2), value = c(0.6,0.8,0.4,0.55,0.87,0.42), type = c("a", "b", "a", "b", "a", "b")) #' create multibarchart using nvd3 of rcharts plot <- nplot(value ~ xaxis, group = 'type', data = mydata, type = 'multibarchart') plot$chart(forcey = c(0.5, 1)) plot$show('iframesrc', cdn = true) ``` bars start low
so forcey not seem work correctly. there easy workaround this?
the easiest workaround save plot , display in iframe. example follows:
--- title: "untitled" author: "sda" output: html_document --- ```{r} library(dplyr) library(tidyr) library(rcharts) library(data.table) ``` ```{r results = 'asis', comment = f, message = f, tidy = f, echo=f, cache=f} mydata <- data.table(xaxis = rep(seq(0,length.out = 3),each = 2), value = c(0.6,0.8,0.4,0.55,0.87,0.42), type = c("a", "b", "a", "b", "a", "b")) plot <- nplot(value ~ xaxis, group = 'type', data = mydata, type = 'multibarchart') plot$chart(ydomain = c(0.5, 1)) plot$save("plot.html", standalone = true) ``` <iframe src="plot.html" height="500" width="900" frameborder="0"></iframe>
note used ydomain
instead of forcey
. did because forcey
displayed graph y=0.4 in computer. however, chart shown correctly using forcey
.
you can find discussion got idea solution here: https://github.com/ramnathv/rcharts/issues/373
Comments
Post a Comment