I've created a Shiny app, which contains some Plotly objects. All works fine when previewing in RStudio. Though, when I deploy the app to Shiny server (on-premise) and open the app, the plots are not shown. When looking at the developer console in the browser (Chrome or Safari) I see the following error Can't find variable: Plotly
which points to line 141 of plotly.js, which is var plot = Plotly.plot(graphDiv, x)
in the following code:
//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;
I tested this in Chrome and Safari, and it happens in both browsers, though when I refresh the page in Chrome the plots sometimes work.
So to test this further, I took this code from the Plotly website, and deployed it to our Shiny server environment to see if the same behaviour occurs, which is the case. As such I don't think I made a coding mistake.
I'm using the following package versions:
- plotly 4.7.1
- shiny 1.0.5
- htmlwidgets 1.0
- Shiny Server v1.5.3.838
Does anyone know how to solve this? Am I missing some packages or does something need to be configured in Shiny server to make this work?
Thanks!