【发布时间】:2019-09-05 16:52:39
【问题描述】:
我正在尝试制作一个仪表板,其中一列中包含绘图图表,另一列中包含数据表。
我需要图表比 DT 大,但 DT 覆盖了 plotly 的大小。
这是一个例子:
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
runtime: shiny
---
<style> #dt{ overflow: auto; } </style>
```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
library(ggplot2)
library(plotly)
diamonds <- diamonds[1:20,]
```
Column {data-width=900}
-----------------------------------------------------------------------
### Chart A
```{r}
plot_ly(diamonds,
x = ~ cut,
y = ~ price,
color = ~ clarity)
```
### Chart B
```{r}
dt <- datatable(diamonds ,options = list(c(scrollY="200px", scrollX=TRUE, pageLength = 100)), filter = 'top')
dt
我一直在尝试不同的方法来指定数据宽度,但到目前为止都没有奏效。
有没有人知道如何让数据表具有水平滚动条?这可能与 flexdashboard 吗?
例如,我希望数据表只显示几列,用户可以滚动查看其余列,这样图表将成为仪表板的主要焦点。
【问题讨论】:
-
虽然我意识到这并不能完全解决您的问题,但在将
vertical_layout:设置为fill时它似乎确实有效。
标签: r datatable r-plotly flexdashboard