Brilliant graphic output rcharts

How can I overwrite the output output parameters with the launch of several diagrams with brilliant and rchart, so the output is a 2x2 grid layout.

require(rCharts) require(shiny) require(data.table) runApp(list( ui = mainPanel( span="span6", showOutput("chart2", "Highcharts"), showOutput("chart3", "Highcharts"), showOutput("chart4", "Highcharts") ), server = function(input, output){ output$chart3 <- renderChart({ a <- hPlot(Pulse ~ Height, data = MASS::survey, type = "bubble", title = "Zoom demo", subtitle = "bubble chart", size = "Age", group = "Exer") a$chart(zoomType = "xy") a$chart(backgroundColor = NULL) a$set(dom = 'chart3') return(a) }) output$chart2 <- renderChart({ survey <- as.data.table(MASS::survey) freq <- survey[ , .N, by = c('Sex', 'Smoke')] a <- hPlot(x = 'Smoke', y = 'N', data = freq, type = 'column', group = 'Sex') a$chart(backgroundColor = NULL) a$set(dom = 'chart2') return(a) }) output$chart4 <- renderChart({ survey <- as.data.table(MASS::survey) freq <- survey[ , .N, by = c('Smoke')] a <- hPlot(x = "Smoke", y = "N", data = freq, type = "pie") a$plotOptions(pie = list(size = 150)) a$chart(backgroundColor = NULL) a$set(dom = 'chart4') return(a) }) } )) 
+6
source share
2 answers

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 brilliant about using the bootstrap library. See http://getbootstrap.com/2.3.2/scaffolding.html for an overview of scaffolding. mainPanel has a width parameter, which defaults to 8. This is span8 in bootstrap. The above code is not perfect, but hopefully its beginning.

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 handy function for divs with widths.

Screenshot:

enter image description here

+6
source

Another solution that is native to R Shiny (without external knowledge of HTML) is to use column ideas.

 ui = mainPanel(fluidPage( fluidRow( column(width=6, showOutput("chart2", "Highcharts"), showOutput("chart3", "Highcharts") ), fluidRow( column(width=6, showOutput("chart4", "Highcharts") ) ) ) )), 
+1
source

All Articles