图表的闪亮rcharts大小?

时间:2014-06-08 10:26:38

标签: r shiny rcharts

我越来越接近生产我想要的东西,但是现在我遇到了调整rChart输出的问题。现在我的输出位于我的第二列的左下角。我希望输出在第二列中居中,如果可能的话,可以调整大小以更好地适应它。

这是我的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")
  )
))

感谢您的帮助!

1 个答案:

答案 0 :(得分:7)

您可以使用$params$width$params$height选项调整地块的大小。您的span6来电与column(9不兼容,span9会宣布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 }) } ) ) ) 类。您可以使用CSS样式选项来对齐您的内容:

{{1}}

enter image description here