Plotly does not display in flexdashboard page

When I try to display a chart from plotly on a new page inside flexdashboard it does not display.
Why is that happening?

Below there is an example.
It is displayed only in the first page but not on the second one.
In the example I put a dot after each r chunk in order to see also the code for the pages in flexdashboard .


title: "Test"
output:
flexdashboard::flex_dashboard



knitr::opts_chunk$set(
	echo = FALSE,
	message = FALSE,
	warning = FALSE
)

library(plotly)
``` . 
    

page 1
===


Column
-------------------------------------
    
### Chart 1
    
```{r chart 1}

density <- state.x77[, "Population"] / state.x77[, "Area"]

g <- list(
  scope = 'usa',
  projection = list(type = 'albers usa'),
  lakecolor = toRGB('white')
)

plot_geo() %>%
  add_trace(
    z = ~density, text = state.name, span = I(0),
    locations = state.abb, locationmode = 'USA-states'
  ) %>%
  layout(geo = g)
``` . 
   
Column
-------------------------------------
   
### Chart 2

```{r}

plot_geo() %>%
  add_trace(
    z = ~density, text = state.name, span = I(0),
    locations = state.abb, locationmode = 'USA-states'
  ) %>%
  layout(geo = g)
``` . 

page 2
===
    
    
```{r }

 plot_geo() %>%
  add_trace(
    z = ~density, text = state.name, span = I(0),
    locations = state.abb, locationmode = 'USA-states'
  ) %>%
  layout(geo = g)
``` .

I solved the issue by downgrading plotly to the version 4.8.0 with the following:
require(devtools)
install_version("plotly", version = "4.8.0", repos = "http://cran.us.r-project.org")

The same issue is open in plotly repo:

1 Like

I believe it is you who open the issue on plotly repo. Nice idea, but do not hesitate to reference in both.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.