代わりの方法は、光沢のある絶対的なパネルを使用することです。画面上のすべての部分に合わせてグリッドアレンジメントを見つけようとするのではなく、特定の時間にどのボックスが表示されるかを選択するためにボタンを折りたたむアブソリュートパネルを使用します。これにより、ユーザーはどのプロットと情報を提示するかを選択できます。このアイデアは、スーパージップアプリhttps://shiny.rstudio.com/gallery/superzip-example.htmlから進化しましたが、flexdashboardでうまく機能します。
以下の例では、ページが読み込まれるときにプロットを表示するか非表示にすることができます。ボタンをクリックすると、そのボタンが表示されたり消えたりします。これは、プロットを使って地図を溺れるのを避けるために、リーフレットとプロットを混在させるときに非常に便利でした(ここで、プロットは溺れた問題のために制限されていました)。
---
title: "Demo"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(rmarkdown)
library(plotly)
library(shiny)
```
Column {data-width=400}
--------------------------------
### Planet Earth
```{r}
library(leaflet)
m = leaflet() %>% addTiles()
m # a map with the default OSM tile layer
```
```{r}
#plot setup
mtcars$am[which(mtcars$am == 0)] <- 'Automatic'
mtcars$am[which(mtcars$am == 1)] <- 'Manual'
mtcars$am <- as.factor(mtcars$am)
p <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E')) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'Weight'),
yaxis = list(title = 'Gross horsepower'),
zaxis = list(title = '1/4 mile time')))
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
##########################
absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
draggable = TRUE, top = 70, left = "auto", right = 20, bottom = "auto",
width = '30%', height = 'auto',
style = "overflow-y:scroll; max-height: 1000px; opacity: 0.9; style = z-index: 400",
h4(strong("Plot Explorer")),
HTML('<button data-toggle="collapse" data-target="#box1" class="btn-block btn-primary">dot plot</button>'),
tags$div(id = 'box1', class="collapse in",
plot_ly(d, x = ~carat, y = ~price, color = ~carat,
size = ~carat, text = ~paste("Clarity: ", clarity)) %>% layout(height=200)
),
HTML('<button data-toggle="collapse" data-target="#box2" class="btn-block btn-warning">histogram</button>'),
tags$div(id = 'box2', class="collapse",
plot_ly(x = rnorm(500), type = "histogram", name = "Histogram") %>% layout(height=200)
),
HTML('<button data-toggle="collapse" data-target="#box3" class="btn-block btn-danger">spinny thing</button>'),
tags$div(id = 'box3', class="collapse in",
p %>% layout(height=200)
)
)
```
サイドバーのレイアウトコントロールを維持し、あなたが提供するレイアウトを持っている任意の方法は? –
@TylerRinkerパネルのように見えるサイドバーに光沢のあるコントロールを配置したい、またはサイドバーのように見えるもう一つのサイドバーをこのレイアウトに追加したいという意味ですか? – dww
後でこのようなものがあります:http://i.imgur.com/VqYbwwC.png –