Shiny和rcdimple htmlwidget - 如何调整容器大小?

时间:2015-10-26 22:27:54

标签: r shiny

在调整浏览器窗口大小时,此示例似乎不适用于当前代码:    https://stackoverflow.com/questions/29211664/controlling-layout-of-multiple-dimple-charts-in-shiny

某些未按预期调整大小的起始代码:

library(shiny)
library(shinydashboard)
library(rcdimple)

## need to eventually plot points over bars, so...
##devtools::install_github("timelyportfolio/rcdimple@feature/layers")

server <- function(input, output) {
  output$test_plot <- renderDimple(
    dimple(x = c('cyl', 'gear'), 
           y = 'mpg',
           groups = 'gear', 
           data = mtcars,
           width = '100%',
           type = 'bar')
  )
}

ui <- dashboardPage(
  dashboardHeader(title = 'test rcdimple'),

  dashboardSidebar(
    verbatimTextOutput('clicked_value')
  ),

  dashboardBody(
    fluidRow(
      box(
        width = 4,
        status = 'info',
        solidHeader = TRUE,
        title = 'test',
        dimpleOutput('test_plot')
      )
    )
  )
)

shinyApp(ui = ui, server = server)



> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] rcdimple_0.1         htmltools_0.2.6     
[3] htmlwidgets_0.5      shinydashboard_0.5.1
[5] shiny_0.12.2        

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.1      lattice_0.20-33  digest_0.6.8    
 [4] mime_0.4         grid_3.2.2       R6_2.1.1        
 [7] xtable_1.7-4     jsonlite_0.9.17  magrittr_1.5    
[10] rstudioapi_0.3.1 tools_3.2.2      httpuv_1.3.3    
[13] yaml_2.1.13 

1 个答案:

答案 0 :(得分:1)

很高兴你使用的是width = "100%"。我相信您只需将ui移至library(shiny) library(shinydashboard) library(rcdimple) ## need to eventually plot points over bars, so... ##devtools::install_github("timelyportfolio/rcdimple@feature/layers") server <- function(input, output) { output$test_plot <- renderDimple( dimple(x = c('cyl', 'gear'), y = 'mpg', groups = 'gear', data = mtcars, type = 'bar') ) } ui <- dashboardPage( dashboardHeader(title = 'test rcdimple'), dashboardSidebar( verbatimTextOutput('clicked_value') ), dashboardBody( fluidRow( box( width = 4, status = 'info', solidHeader = TRUE, title = 'test', dimpleOutput('test_plot',width="100%") ) ) ) ) shinyApp(ui,server)

{{1}}