2017-09-19 4 views
0

私はいくつかのチャートで光沢のあるモジュールを使用していますが、すべてうまくいきます(驚くべき機能です)...しかし、それらをvalueBox(shinydashboard)与えられた例parameteres「数」と「メトリック」を明示的に提供されてshinyモジュールをvalueBoxで動作させることはできません

library(shinydashboard) 

# MODULE UI 
bsc_tile_UI <- function(id) { 
    ns <- NS(id) 
    valueBoxOutput("tile1", width=12) 
} 

# MODULE Server 
bsc_tile_OUT <- function(input, output, session, number, metric) { 
    output$tile1 <- renderValueBox({ 
    valueBox(number, paste(metric), icon = icon("arrow-up"),color = "blue", 
    width=12) 
    }) 
} 

ui<-dashboardPage(
     dashboardHeader(title = "Dashboard"), 
     sidebar <- dashboardSidebar(disable = TRUE), 
     dashboardBody(
     fluidPage(
      bsc_tile_UI("tile_1"), 
      bsc_tile_UI("tile_2") 
     ) 
     ) 
    ) 

# App server 
server <- function(input, output,session){ 
    callModule(bsc_tile_OUT, "tile_1", '300', 'metric 1') 
    callModule(bsc_tile_OUT, "tile_2", '500', 'metric 2') 
} 

shinyApp(ui, server) 

が、私の意図は、それらがデータフレームの変数として定義されますです:何も はここで、最小限の例です...レンダリングされません。

何か歓迎されます! (申し訳ありませんmy english)

+0

あなたがrenderUIを(使用してみました)の代わりにrenderValueBoxの?これは回避策ですが、問題が解決する可能性があります。 – thisislammers

+0

renderUIを使用するsuccesはありません。 – COLO

答えて

1

定義済みのすべてのモジュール入力でns()を使用する必要があります。モジュールサーバーは出力ベクトルのメンバーを取得しており、内部的にモジュールID(あなたの場合は「tile_1」と「tile_2」)を添付します。これはns()を使用してUIで手動で行う必要があります。だから、あなただけの次に、あなたのモジュールのUI出力定義を変更した場合、あなたのコードは動作します:

valueBoxOutput(ns("tile1"), width=12)

enter image description here

+0

shosaco、あなたは私の日を救った!それは完璧に働いた。ありがとう! – COLO

関連する問題