R flexdashboard垂直滚动切断图表

R flexdashboard vertical scroll cutting off graphs

我正在尝试制作一个垂直滚动的 flexdashboard。有时,垂直滚动不能正常工作,较低的图形被截断。这可以通过使 window 变窄来“修复”,然后它会滚动,但显然这不是一个可接受的解决方案。

下面是代码,还有滚动不佳的截图。可以看到最终图的内容被截掉了。我还附上了所需滚动行为的图片。我知道代码片段有点长,但是滚动行为当然只有在适当数量的图表中才会明显。

这是所需的滚动行为:

这里是截取的滚动条和隐藏图:

---
title: "Untitled"
output: flexdashboard::flex_dashboard
orientation: row
vertical_layout: scroll

---

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

dataset <- mtcars
```

Page 1
================================

Row
-----------------------------------------------------------------------


### ValueBox 1

```{r}
valueBox(42, caption = "my caption", icon = "fa-calendar")
```   
### ValueBox 2

```{r}
valueBox(250, caption = "my caption", icon = "fa-calendar")
``` 

### Additional Info


```{r}

sector_levels <- gaugeSectors(success = c(0, 40),
                              warning = c(40, 60),
                              danger = c(60, 100),
                              colors= c("red", "yellow", "green"))


g1 <- gauge(25, min = 0, max = 100, sectors = sector_levels)
g2 <- gauge(75, min = 0, max = 100, sectors = sector_levels)

g1
g2
```
###  Chart B 
```{r}
color_map <- c("4" = "red", "6" = "green", "8"  ="blue")


plot1 <- plot_ly(data = dataset, x = ~dataset$cyl, color = ~as.factor(cyl), colors = color_map,
  type = "histogram")

plot1 <- plot1 %>% layout(legend = c, xaxis = list(title = "Also a Test"))

plot1
```

如果有人感兴趣,我已经通过在 CSS 中应用最小高度值来管理解决方法。所需的 CSS 代码是:

.chart-stage-flex{
  min-height: 500px;
}

这可能是一个 hack,但似乎按预期工作。