dwi*_*sen 6 r shiny shiny-server plotly
我创建了一个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;
Run Code Online (Sandbox Code Playgroud)
我在Chrome和Safari中对此进行了测试,并且它在两种浏览器中都会出现,但是当我在Chrome中刷新页面时,图表有时会起作用.
因此,为了进一步测试,我从Plotly网站获取此代码,并将其部署到我们的Shiny服务器环境中,以查看是否出现相同的行为,情况就是如此.因此我不认为我犯了编码错误.
我正在使用以下软件包版本:
有谁知道如何解决这个问题?我是否遗漏了一些软件包或是否需要在Shiny服务器中配置某些软件才能使其正常工作?
谢谢!
小智 0
我认为您可能需要的是 renderPlotly 而不是服务器中的 renderPlot 。如果这样做,绘图将显示在查看器上,但不会显示在闪亮的弹出窗口(空白图表)中,并且在部署时将不起作用。renderPlot 已被 renderPlotly 取代的示例如下:
ui <- dashboardPage(skin = "blue",
dashboardHeader(title= "Fig. 11: State Forecasting and Nowcasting", titleWidth = 450),
dashboardSidebar(disable=TRUE),
dashboardBody(
fillPage(padding = 0,
box(title="", id="normal", solidHeader = TRUE, status = "primary", width=7,
plotlyOutput("plot1", height = 250)),
box(title="State to Examine", background = "black", width=5,
selectInput("variable", "State:", choices= sort(unique(afteradd2$State)), selected="Ohio")),
box(title="Forecast Length", background = "black", width=5,
selectInput("variable.two", "Forecast:", choices= c("Nowcast", "Three Month Forecast",
"Six Month Forecast"), selected="Nowcast"))
)))
server <- function(input, output) {
output$plot1<- renderPlotly({
par(mfrow=c(1,1))
par(mar = c(4, 5, 4, 4))
fstate(input$variable, input$variable.two)})}
shinyApp(ui=ui, server=server)
Run Code Online (Sandbox Code Playgroud)
如果没有看到您的代码,就很难确定。如果这不是您的问题,您可以分享您的代码以便我可以提供帮助吗?
| 归档时间: |
|
| 查看次数: |
177 次 |
| 最近记录: |