r - Automatically resize rChart in shiny -
how can automatically resize rchart plot in shiny? fit plot screen of user, done regular plots renderplot. here's minimal example:
#server.r require(rcharts) shinyserver(function(input, output) { output$chart1 <- renderchart2({ r1 <- rplot(mpg ~ wt | + vs, data = mtcars, type = "point", color = "gear") return(r1) }) }) #ui.r. require(rcharts) options(rchart_lib = 'polycharts') shinyui(shinyui(fluidpage( titlepanel("title panel"), sidebarlayout( sidebarpanel("sidebar panel"), mainpanel("main panel", chartoutput("chart1", 'polycharts')) ) ) )) i tried adding:
w <- session$clientdata$output_chart1_width r1$set(width = w) but not work.
you there: rchart's chartoutput doesn't pass size, workaround use plotoutput object this.
here solution works me:
#server.r require(rcharts) shinyserver(function(input, output, session) { output$chart1 <- renderchart2({ r1 <- rplot(mpg ~ wt | + vs, data = mtcars, type = "point", color = "gear") r1$set(width = session$clientdata$output_plot1_width) return(r1) }) }) #ui.r require(rcharts) options(rchart_lib = 'polycharts') shinyui(shinyui(fluidpage( titlepanel("title panel"), sidebarlayout( sidebarpanel("sidebar panel"), mainpanel("main panel", plotoutput("plot1", height = "1px"), chartoutput("chart1", 'polycharts') ) ) ) )) note: here example wrote nvd3 type chart: https://gist.github.com/nassimhaddad/3057e9ac687591fa5138
Comments
Post a Comment