【问题标题】:HTMLWidget: Shiny app run well in Rstudio but Not on Shiny-ServerHTMLWidget:Shiny 应用程序在 Rstudio 中运行良好,但在 Shiny-Server 上运行良好
【发布时间】:2017-11-16 20:08:00
【问题描述】:

最近我编写了一个 html 小部件来使用 javascript 文件来绘制维恩图。在 RStudio 中,该应用程序运行良好,所以到目前为止我还没有意识到在闪亮的服务器上使用该应用程序存在问题。

如果我在 RStudio 中使用 Shiny 运行应用程序,则不会引发错误,并且 Web 浏览器会显示我的 Shiny 页面的所有其他元素,但新小部件除外。考虑到浏览器的开发者控制台,我看到以下错误,这对我来说有点神秘。

Uncaught TypeError: Cannot read property 'filter' of undefined
at exports.OutputBinding.shinyBinding.find (htmlwidgets.js:475)
at a (shiny.min.js:3)
at f (shiny.min.js:3)
at initShiny (shiny.min.js:3)

我也在 RStudio 之外运行它只是为了确定但同样的错误。

我已经用 2 个独立的软件包对此进行了测试,所以这似乎是我这边的系统性错误。

通过在浏览器中检查正在运行的应用程序,我看到创建了以下 div。但是,我找不到提交的数据。

<div id="vennDia" style="width:100%; height:400px; " class="vennConductor html-widget html-widget-output"></div>

vennConductor.js:

HTMLWidgets.widget({
  name: 'vennConductor',
  type: 'output',

 initialize: function(el, width, height) {
    },
    renderValue: function(el, x, instance) {
        // console.log(x)
        $(el).jvenn(x)},
    resize: function(el, width, height, instance) {
        $(el).attr("width", width).attr("height", height)
    }
});

在我看来“相关”的 HTMLWidget R 代码:

htmlwidgets::createWidget(
    name = 'vennConductor',
    json_payload,
    width = width,
    height = height,
    package = 'vennConductor',
    elementId = elementId,
    sizingPolicy = htmlwidgets::sizingPolicy(
      browser.fill = TRUE,
      viewer.fill = TRUE
    )
  )


#' @name vennConductor-shiny
#' @export
vennConductorOutput <- function(outputId, width = '100%', height = '400px'){
  htmlwidgets::shinyWidgetOutput(outputId, 'vennConductor', width, height, package = 'vennConductor')
}

#' @rdname vennConductor-shiny
#' @export
renderVennConductor <- function(expr, env = parent.frame(), quoted = FALSE) {
  if (!quoted) { expr <- substitute(expr) } # force quoted
  htmlwidgets::shinyRenderWidget(expr, vennConductorOutput, env, quoted = TRUE)
}

和小部件调用:

jVennConductor(elementId = 'vennDia', venn_lists = vlist_01, displayMode=T, displayStat=T)

希望任何人都可以帮助我。谢谢!!!

P.s.:R 和 a 包是最新的,我的操作系统是 WINDOWS 10。

【问题讨论】:

    标签: javascript r shiny htmlwidgets


    【解决方案1】:

    我们找到了问题的原因。 Shiny 以小写字母导入 jquery,以大写字母导入 jVennConductor,这就是导致错误的原因。将两者都更改为小写即可解决问题。

    感谢 Joe Cheng​​p>

    https://github.com/ramnathv/htmlwidgets/issues/253

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 1970-01-01
      • 2020-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      相关资源
      最近更新 更多