Shiny rcharts size of the graph?
Asked Answered
H

1

5

I'm getting closer to produce what I want, but Now i'm having troubles resizing and aligning the rChart output. Right now my output is in the lower left corner of my second column. I would like the output to be centered in the second column and if possible to get resized to fit it better.

This is my ui.R:

require(rCharts)
shinyUI(fluidPage(
  titlePanel("Quiz 3 grades distribution"),

  fluidRow(
    column(3,
      #helpText("Select grade in Quiz 1 before the treatment:"),    
      selectInput("select", label = h3("Grade Quiz 1 before the treatment:"), 
                  choices = list("All" = 0, "Not Perfect" = 1, "Perfect" = 2), 
                  selected = 0)
    ),

    column(9, showOutput("histogram","nvd3"), class = "span6")
  )
))

Thanks for the help!

Hopkins answered 8/6, 2014 at 10:26 Comment(1)
Please consider providing a reproducible example. If your question is shiny related you can use runApp to do this.Mannes
M
7

You can adjust the size of your plot using $params$width and $params$height options. Your span6 call is not compatible with column(9 which will declare a class of span9. You can use a CSS style option to align your content:

library(rCharts)
library(shiny)
X <- data.frame(Var1 = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L,3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L),
                Var2 = structure(c(1L,1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("control","treatment1", "treatment2"), class = "factor"),
                Freq = c(0L,0L, 3L, 2L, 6L, 9L, 13L, 36L, 50L, 497L, 0L, 2L, 1L, 3L, 6L, 4L, 11L, 29L, 50L, 499L, 1L, 2L, 0L, 2L, 5L, 6L, 12L, 22L, 63L,490L)
)
runApp(
  list(ui = fluidPage(
    titlePanel("Quiz 3 grades distribution"),

    fluidRow(
      column(3,
             #helpText("Select grade in Quiz 1 before the treatment:"),    
             selectInput("select", label = h3("Grade Quiz 1 before the treatment:"), 
                         choices = list("All" = 0, "Not Perfect" = 1, "Perfect" = 2), 
                         selected = 0)
      ),

      column(9, div(showOutput("histogram","nvd3")), style = 'align:center;')
    )
  ),
  server = shinyServer(
    function(input, output, session) {
      output$histogram <- renderChart2({
        n2 <- nPlot(Freq ~ Var1, group = 'Var2', data = X, type = 'multiBarChart')
        n2$params$width <- 500
        n2$params$height <- 400
        n2
      })
    }
  )

  )
)

enter image description here

Mannes answered 8/6, 2014 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.