【发布时间】:2018-08-10 10:28:07
【问题描述】:
我创建了一个 Shiny 应用程序,其中包含一些 Plotly 对象。在 RStudio 中预览时一切正常。但是,当我将应用程序部署到 Shiny 服务器(本地)并打开应用程序时,未显示绘图。在浏览器(Chrome 或 Safari)中查看开发者控制台时,我看到以下错误 Can't find variable: Plotly,它指向 plotly.js 的第 141 行,在以下代码中为 var plot = Plotly.plot(graphDiv, x):
//if no plot exists yet, create one with a particular configuration
if (!instance.plotly) {
var plot = Plotly.plot(graphDiv, x);
instance.plotly = true;
instance.autosize = x.layout.autosize || true;
instance.width = x.layout.width;
instance.height = x.layout.height;
我在 Chrome 和 Safari 中对此进行了测试,并且在两种浏览器中都发生了这种情况,但是当我在 Chrome 中刷新页面时,绘图有时会起作用。
所以为了进一步测试这一点,我从 Plotly 网站上获取了this code,并将其部署到我们的 Shiny 服务器环境中,看看是否会发生相同的行为,是这种情况。因此,我不认为我犯了编码错误。
我正在使用以下软件包版本:
- 情节4.7.1
- 闪亮的 1.0.5
- htmlwidgets 1.0
- 闪亮服务器 v1.5.3.838
有谁知道如何解决这个问题?我是否遗漏了一些软件包,或者是否需要在 Shiny 服务器中配置某些东西才能使其正常工作?
谢谢!
【问题讨论】:
-
您的服务器上是否安装了 rstudio 服务器?您可以尝试在 rstudio 中运行您的代码,看看它是否可以帮助您检测到您遇到的问题。
-
我们确实在同一台服务器上安装了该应用程序,我也从 rstudio 尝试了该应用程序。它工作正常并且绘图显示正确。将应用部署到闪亮服务器时会出现问题。
-
我也有一个非常相似的问题。如果我在这里使用他们提供的示例,我也会收到 500 错误:plotly-r.com/linking-views-with-shiny.html
标签: r shiny plotly shiny-server