plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.55k stars 623 forks source link

Plotly heatmap in a flexdashboard document #1524

Closed Haunfelder closed 5 years ago

Haunfelder commented 5 years ago

I’m having a very specific problem with a plotly heatmap object inserted in a two tabbed flexdashboard rmarkdown. The MRE below, when rendered, displays an uncaught axis resizing javascript error. The error causes the heatmap to not render on the second tab. However, if the heatmap is moved to the same tab both will render without a problem. The craziest part is that a hard refresh of the html document (ctrl+f5 in browser) with the second tab open causes the javascript error to disappear and everything renders just fine. I am using the most current version of all packages on CRAN and the newest R release 3.6.0. I am having a very difficult time isolating this issue to the plotly R API, but I believe the most recent update is the source of the issue since I cannot reproduce in an older verison of R (3.5.2) and version of plotly (4.8.0.9000). Any ideas?

SO Post

---
title: "`r paste0('Test')`"
date: "`r Sys.Date()`"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: scroll
    orientation: rows
    self_contained: false
---

```{r setup, include=FALSE}
library(flexdashboard)
library(reshape2)
library(dplyr)
library(ggplot2)
library(plotly)

Tab1

Row

A scatter

df = data.frame(x = 1:5, y = 1:5, z = 1:5)
plot_ly(df, x = ~x, y = ~y, type = "scatter")

Tab2

Row

A heatmap

plot_ly(df, x = ~x, y = ~y, z = ~z, type = "heatmap")
cpsievert commented 5 years ago

Probably a duplicate of #1546

cpsievert commented 5 years ago

Looks like you can workaround this problem by doing:

plot_ly(df, x = ~x, y = ~y, z = ~z, type = "heatmap") %>%
  config(fillFrame = TRUE)
cpsievert commented 5 years ago

Closing since this is a duplicate of #1546 (and there is more/better information there)