Shiny rcharts multiple chart output

与世无争的帅哥 提交于 2019-11-28 10:20:28
jdharrison

Change ui to:

ui = bootstrapPage(mainPanel( 
      div(class = "row",
        div(showOutput("chart2", "Highcharts"), class = "span4"),
        div(showOutput("chart3", "Highcharts"), class = "span4")
      ),
      div(class = "row",
        div(showOutput("chart4", "Highcharts"), class = "span4")
      )
    ))

Add bootstrapPage to tell shiny to use the bootstrap library. Look at http://getbootstrap.com/2.3.2/scaffolding.html to get an idea of "scaffolding". mainPanel has a width option which defaults to 8. This is span8 in bootstrap. The above code is not ideal but hopefully its a start.

EDIT: For full screen

ui = bootstrapPage(mainPanel(width = 12,  
      div(class = "row",
        div(showOutput("chart2", "Highcharts"), class = "span6"),
        div(showOutput("chart3", "Highcharts"), class = "span6")
      ),
      div(class = "row",
        div(showOutput("chart4", "Highcharts"), class = "span6")
      )
    ))

note that mainPanel(..., width = width) is just a convenience function for div with a span of width.

A screenshot of the result:

Another solution that is native to R Shiny (without the outside knowledge of HTML), is to use the ideas of columns.

ui = mainPanel(fluidPage(
    fluidRow(
      column(width=6, 
             showOutput("chart2", "Highcharts"),
             showOutput("chart3", "Highcharts")
    ),
    fluidRow(
      column(width=6, 
             showOutput("chart4", "Highcharts") 
        )
      )
    )
  )),
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!