如何在闪亮的 flexdashboard 标签集布局中正确调整 dygraph 小部件的大小?

How can I size a dygraph widget properly within a flexdashboard tabset layout in shiny?

在 R 中,我正在创建一个 shiny 应用程序,其布局 flexdashboard 使用选项卡。 我想在其中一个选项卡中包含 dygraph,但图表超出了容器范围。 我尝试更改 dygraph 和输出中的宽度和高度,但其中 none 似乎有效。

最小工作示例:

---
title: "Example"
output: 
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---

```{r global, include=FALSE}
library(dygraphs)
data=data.frame(x=1:10,y=11:20,val=21:30)

ymin=min(data$y,na.rm=TRUE)
ymax=max(data$y,na.rm=TRUE)

```

TABS {.tabset}
-----------------------------------------------------------------------

### Tab1



```{r singleSlider }
sliderInput("sliceval", "Observation:",
            min = ymin, max = ymax,step=1,
            value = 11,width="90%")



```

```{r dygraph}

# Tried also changing height width to px
output$sliceGraph <- renderDygraph({
  dygraph(data[input$sliceval>=data$y,c("x","val")],height="50%",width="80%")
})

# Tried also changing height width to %
dygraphOutput("sliceGraph",height='100px',width='100px')


```

### Tab 2 

Some stuff here

有没有办法让 dygraph 适合这样的布局?

我会再次查看 documentation for using flexdashboard 并使用他们推荐的 fillColfillRow 进行更多控制。具体来说,试试这个布局:

```{r singleSlider, echo=FALSE}
fillCol(height = 600, flex = c(NA, 1),
  sliderInput("sliceval", "Observation:",
            min = ymin, max = ymax,step=1,
            value = 11,width="90%"),
  # Tried also changing height width to %
  dygraphOutput("sliceGraph",height='400px',width='100%')
)


# Tried also changing height width to px
output$sliceGraph <- renderDygraph({
  dygraph(data[input$sliceval>=data$y,c("x","val")],height="50%",width="80%")
})
```