Shiny lealfet上的Flexdashboard和absolute面板

Shiny lealfet上的Flexdashboard和absolute面板,shiny,panel,flexdashboard,Shiny,Panel,Flexdashboard,是否有办法将本例()中的绝对面板包含到flexdashboard(在传单上)? 我们的想法是用一个移动面板代替边栏面板,专门用于传单输出 这里的绝对面板示例基于一个闪亮的示例(带有ui和服务器部件) 库(闪亮) ui试试这个 --- title: "haha" output: flexdashboard::flex_dashboard: orientation: columns vertical_layout: fill editor_options: chunk_ou

是否有办法将本例()中的绝对面板包含到flexdashboard(在传单上)? 我们的想法是用一个移动面板代替边栏面板,专门用于传单输出

这里的绝对面板示例基于一个闪亮的示例(带有ui和服务器部件)

库(闪亮)
ui试试这个

---
title: "haha"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
editor_options: 
  chunk_output_type: console
runtime: shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(flexdashboard)
library(shiny)
library(leaflet)
```

# without container-fluid

### Sites on campus

```{r}
df <- data.frame(NY = c(-74.418997, 43.257408), CA = c(-120.765285, 35.604380))
renderLeaflet(mapfunction())


```


```{r}

absolutePanel(
        draggable = TRUE, top = "15%", left = "auto", right = "5%", bottom = "auto",
        width = '30%', height = 'auto',
        style = "background: orange; opacity: 0.9",
        p(strong("some text")),
        selectInput("someinput", label = "location", choices = c("NY", "CA"))
    )

```

### server
```{r}
mapfunction <- reactive({
    leaflet() %>% 
    addTiles() %>% 
    fitBounds(-127.44,24.05,-65.30,50.35) %>% 
    addMarkers(lng = df[[input$someinput]][1], lat =  df[[input$someinput]][2])
})
```

# with container-fluid
```{r}
shinyApp(
    fluidPage(
        leafletOutput(outputId = "somemap"),
        absolutePanel(
            draggable = TRUE, top = "15%", left = "auto", right = "5%", bottom = "auto",
            width = '30%', height = 'auto', fixed = TRUE,
            style = "background: orange; opacity: 0.9",
            p(strong("some text")),
            selectInput("someinput", label = "location", choices = c("NY", "CA"))
        )
    ),
    server = function(input, output, session){
        df <- data.frame(NY = c(-74.418997, 43.257408), CA = c(-120.765285, 35.604380))
        output$somemap <- renderLeaflet({
        leaflet() %>% 
            addTiles() %>% 
            fitBounds(-127.44,24.05,-65.30,50.35) %>% 
            addMarkers(lng = df[[input$someinput]][1], lat =  df[[input$someinput]][2])
        })
    }
)

```
---
标题:“哈哈”
输出:
flexdashboard::flex_仪表板:
方向:列
垂直布局:填充
编辑器选项:
块输出类型:控制台
运行时间:闪亮
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
库(flexdashboard)
图书馆(闪亮)
图书馆(单张)
```
#无容器液体
###校园网站
```{r}
df%
fitBounds(-127.44,24.05,-65.30,50.35)%>%
addMarkers(lng=df[[input$someinput]][1],lat=df[[input$someinput]][2])
})
```
#使用容器流体
```{r}
shinyApp(
流动摄影(
传单输出(outputId=“somemap”),
绝对专家组(
draggable=TRUE,top=“15%”,left=“auto”,right=“5%”,bottom=“auto”,
宽度='30%',高度='auto',固定=TRUE,
style=“背景:橙色;不透明度:0.9”,
p(强(“某些文本”),
selectInput(“someinput”,label=“location”,choices=c(“NY”,“CA”))
)
),
服务器=功能(输入、输出、会话){
df%
fitBounds(-127.44,24.05,-65.30,50.35)%>%
addMarkers(lng=df[[input$someinput]][1],lat=df[[input$someinput]][2])
})
}
)
```
  • 如果需要使用Shinny中的交互式组件,如XXinput,则需要在顶部指定
    runtime:shinny
    ,否则,可以删除此行
  • 我使用
    reactive
    作为最简单的服务器部分。如果要使用更复杂的服务器(逻辑),例如多个组件一起交互,则需要编写实际的
    server
    函数。我建议只编写一个闪亮的应用程序,而不是flexdashboard
  • 不幸的是,flexdash中的组件不在
    容器流体
    类中,使用该类可以拖动面板。可能有一种解决方法,你可以搜索它。看最后一个chunck,我插入了一个真正闪亮的应用程序,面板可以拖动。运行文档时,您应该会看到两个选项卡,观察差异。所以,如果你真的想拖动这个面板,你应该写一个“真正”闪亮的应用程序
---
title: "Waste Lands - America's forgotten nuclear legacy"
author: Philipp Ottolinger
output: 
  flexdashboard::flex_dashboard:
    theme: journal
    social: menu
    source_code: embed
---

```{r setup, include = FALSE}
library(flexdashboard)
library(shiny)
library(jsonlite)
library(maptools)
library(ggplot2)
library(tidyr)
library(dplyr)
library(purrr)
library(leaflet)
library(plotly)

sites <- fromJSON(flatten=TRUE,
  "https://raw.githubusercontent.com/ottlngr/2016-15/ottlngr/ottlngr/sites.json")

sites$locations <- map(sites$locations, function(x) {
  if (nrow(x) == 0) {
    data_frame(latitude=NA, longitude=NA, postal_code=NA, name=NA, street_address=NA)
  } else {
    x
  }
})

sites <- unnest(sites)
sites <- sites[complete.cases(sites[,c("longitude", "latitude")]),]

sites$ratingcol <- ifelse(sites$site.rating == 0, "orange",
                          ifelse(sites$site.rating == 1, "green",
                                 ifelse(sites$site.rating == 2, "red", "black")))

sites$ratingf <- factor(sites$site.rating,
                        levels=c(3:0),
                        labels=c("Remote or no potential for radioactive contamination.",
                                 "No authority to clean up or status unclear.",
                                 "Cleanup declared complete.",
                                 "Cleanup in progress."))

sites$campus <- ifelse(grepl("University", sites$site.name) | 
                       grepl("University", pattern = sites$street_address) | 
                       grepl("Campus", sites$street_address), 1, 0)
sites$campuscol <- ifelse(sites$campus == 1, "red", "black")
```

Column {data-width=650}
-----------------------------------------------------------------------

### All sites and their current status

```{r}
leaflet() %>% 
  addTiles() %>% 
  fitBounds(-127.44,24.05,-65.30,50.35) %>% 
  addCircleMarkers(sites$longitude, 
                   sites$latitude, 
                   color = sites$ratingcol, 
                   radius = 6, 
                   fill = T,
                   fillOpacity = 0.2,
                   opacity = 0.6,
                   popup = paste(sites$site.city,
                                 sites$site.name, 
                                 sep = "")) %>%
  addLegend("bottomleft", 
            colors = c("orange","green", "red", "black"),
            labels = c("Cleanup in progress.",
                       "Cleanup complete.",
                       "Status unclear.",
                       "No potential for radioactive contamination."), 
            opacity = 0.8)
```

Column {data-width=350}
-----------------------------------------------------------------------

### Number of sites

```{r}
sites %>% 
  count(ratingf) %>%
  plot_ly(type = "bar", 
          x = ratingf, 
          y = n, 
          color = ratingf, 
          text = paste(n,ratingf,sep=""), 
          hoverinfo = "text") %>%
  layout(xaxis = list(showline = F, 
                      showticklabels = F, 
                      fixedrange = T, 
                      title = ""),
         yaxis = list(fixedrange = T, 
                      title = ""))
```

### Sites on campus

```{r}
leaflet() %>% 
  addTiles() %>% 
  fitBounds(-127.44,24.05,-65.30,50.35) %>% 
  addCircleMarkers(sites[sites$campus == 1, ]$longitude, 
                   sites[sites$campus == 1, ]$latitude, 
                   color = sites[sites$campus == 1, ]$campuscol, 
                   radius = 6, 
                   fill = T,
                   fillOpacity = 0.2,
                   opacity = 0.6,
                   popup = paste(sites[sites$campus == 1, ]$site.city,
                                 sites[sites$campus == 1, ]$site.name, 
                                 sep = ""))
```
---
title: "haha"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
editor_options: 
  chunk_output_type: console
runtime: shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(flexdashboard)
library(shiny)
library(leaflet)
```

# without container-fluid

### Sites on campus

```{r}
df <- data.frame(NY = c(-74.418997, 43.257408), CA = c(-120.765285, 35.604380))
renderLeaflet(mapfunction())


```


```{r}

absolutePanel(
        draggable = TRUE, top = "15%", left = "auto", right = "5%", bottom = "auto",
        width = '30%', height = 'auto',
        style = "background: orange; opacity: 0.9",
        p(strong("some text")),
        selectInput("someinput", label = "location", choices = c("NY", "CA"))
    )

```

### server
```{r}
mapfunction <- reactive({
    leaflet() %>% 
    addTiles() %>% 
    fitBounds(-127.44,24.05,-65.30,50.35) %>% 
    addMarkers(lng = df[[input$someinput]][1], lat =  df[[input$someinput]][2])
})
```

# with container-fluid
```{r}
shinyApp(
    fluidPage(
        leafletOutput(outputId = "somemap"),
        absolutePanel(
            draggable = TRUE, top = "15%", left = "auto", right = "5%", bottom = "auto",
            width = '30%', height = 'auto', fixed = TRUE,
            style = "background: orange; opacity: 0.9",
            p(strong("some text")),
            selectInput("someinput", label = "location", choices = c("NY", "CA"))
        )
    ),
    server = function(input, output, session){
        df <- data.frame(NY = c(-74.418997, 43.257408), CA = c(-120.765285, 35.604380))
        output$somemap <- renderLeaflet({
        leaflet() %>% 
            addTiles() %>% 
            fitBounds(-127.44,24.05,-65.30,50.35) %>% 
            addMarkers(lng = df[[input$someinput]][1], lat =  df[[input$someinput]][2])
        })
    }
)

```