【问题标题】:r dygraph and shiny modulesr dygraph 和闪亮的模块
【发布时间】:2016-07-25 14:20:39
【问题描述】:

我开始为我的 UI 和服务器使用闪亮的模块。我对 dygraph 图例的显示有一个特定的问题。

在使用闪亮的模块之前,我可以在我的 UI 中显示图表和图例。一旦我使用了这些模块,它就停止了工作。难道dygraph的传说不是反应输出?

没有闪亮的模块(有效)

...

tabPanel("Plot",dygraphOutput("plot1"),

    textOutput("legendDivID"))
...

dygraph 服务器代码:

output$plot1 <- renderDygraph({

    dygraph(dfplot())%>% 
    dyLegend(labelsDiv = "legendDivID", labelsSeparateLines = T)%>% 
    dyRangeSelector()
  })

现在我构建闪亮的模块

StockUI<-function(id, label= "aaa"){
  ns <- NS(id)#Named space
...
tabPanel("Plot",dygraphOutput(ns("plot1")),
                             textOutput(ns("legendDivID"))}

Stock <- function(input,output,session){
...
output$plot1 <- renderDygraph({dygraph(foo())%>% 
      dyLegend(labelsDiv = "legendDivID", labelsSeparateLines = T)%>% 
      dyRangeSelector()
  }) 
}

但是 Legend 不再显示,它在闪亮的模块之外工作正常。

【问题讨论】:

    标签: r shiny dygraphs


    【解决方案1】:

    您在 UI 中的 legendDivId 被包裹在 ns 中,因此它也应该被包裹在服务器中的 ns 中。服务器中的ns可以通过server$ns进行评估。这应该有效:

    output$plot1 <- renderDygraph({dygraph(foo())%>% 
          dyLegend(labelsDiv = session$ns("legendDivID"), labelsSeparateLines = T)%>% 
          dyRangeSelector()
      }) 
    

    【讨论】:

      猜你喜欢
      • 2021-06-19
      • 1970-01-01
      • 2015-07-22
      • 1970-01-01
      • 2021-07-17
      • 2017-12-09
      • 2021-01-31
      • 2019-08-14
      • 1970-01-01
      相关资源
      最近更新 更多