Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic resizing of ggvis plots in shiny apps

Tags:

r

shiny

ggvis

When adding a ggvis plot to a shiny app, the width and height of the plot are fixed and don't automatically adjust to the size of the div the ggvis object is placed in. This obviously causes some problems when app users have different screen sizes for instance, or adjust the size of the app window.

It's possible to modify the size of the ggvis object on the server side using set_options, but this doesn't really help since I don't think there is a way to pass the size of the div to the server side.

I've tried modifying the css of the different classes associated with the ggvis object on the ui side (e.g. ggvis-output, ggvis-output-container, etc.) but this doesn't help either. The ggvisOutput function seems to override the css length and width no matter what.

Has anybody found a solution/workaround to dynamically resize a ggvis plot as function of the size of the surrounding div?

Thanks for your help.

like image 542
Simon Garnier Avatar asked Dec 29 '14 17:12

Simon Garnier


Video Answer


1 Answers

This is now possible in the development version of ggvis. See https://github.com/rstudio/ggvis/pull/381

like image 126
wch Avatar answered Oct 23 '22 10:10

wch