dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

Rstudio viewer and new window resizing

Open ghost opened this issue 7 years ago • 3 comments

Hi, I'm trying to plot multiple charts in rstudio viewer using htmltools::browsable and tagList. The code is something like this.

htmltools::browsable( htmltools::tagList( dygraphs::dygraph(data, group = "test",height="250",width="95%",main="test"), dygraphs::dygraph(data1, group = "test", height = "200" ,width ="95%") ) )

This code works perfect in rstudio viewer, but when opened in the new window, it does not scale to fit the new window. Only the width works and thats probably because its in percentage terms. I tried changing the height to 50% for both graphs but it didnt work.

Any help on this would be greatly appreciated.

ghost avatar Nov 13 '17 04:11 ghost

Could you please provide a Minimal Working Example (https://www.r-bloggers.com/writing-a-minimal-working-example-mwe-in-r/)?

przmv avatar Nov 13 '17 07:11 przmv

Okay so basically this works, but it doesn't automatically resize when you open it in a new window.

data<-xts::xts(1:10, as.POSIXlt(1366039619, tz="GMT", origin="1970-01-01") + rnorm(10, 500000, 250000)/1000000) data1<-xts::xts(1:10, as.POSIXlt(1366039619, tz="GMT", origin="1970-01-01") + rnorm(10, 500000, 250000)/1000000) htmltools::browsable( htmltools::tagList( dygraphs::dygraph(data, group = "test",height="250",width="95%",main="test"), dygraphs::dygraph(data1, group = "test", height = "200" ,width ="95%") ) )

Perhaps specifying the height as a percentage will work, but this method doesnt :(

data<-xts::xts(1:10, as.POSIXlt(1366039619, tz="GMT", origin="1970-01-01") + rnorm(10, 500000, 250000)/1000000) data1<-xts::xts(1:10, as.POSIXlt(1366039619, tz="GMT", origin="1970-01-01") + rnorm(10, 500000, 250000)/1000000) htmltools::browsable( htmltools::tagList( dygraphs::dygraph(data, group = "test",height="50%",width="95%",main="test"), dygraphs::dygraph(data1, group = "test", height = "50%" ,width ="95%") ) )

ghost avatar Nov 13 '17 08:11 ghost

I have a similar issue where fig.width, width and everything else has no effect in the notebook preview. The width is limited to a fixed value .

The problem seems to be from htmltools, not dygraph.

Minimal example:

htmltools::browsable(kable(mtcars, format="html"))

devereaux avatar Dec 02 '17 00:12 devereaux