问题描述
我在.navbar-right
中创建了一个下载按钮。
我想将该按钮链接到downloadHandler()
函数,该函数将基于包含仪表板图表1的“ report.Rmd”生成一个.pdf报告。有人知道如何做到这一点吗?
我试图在导航栏中创建一个闪亮的下载按钮,但它始终会显示在其正下方。
这是应用程序
---
title: "COVID-19 Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
navbar:
- { icon: "fa-download",href: "#",align: right }
social: menu
date: "`r Sys.Date()`"
runtime: shiny
---
```{r setup,include=FALSE}
library(flexdashboard)
library(knitr)
library(shiny)
library(tidyverse)
library(highcharter)
mdc_c19 <- read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-
counties.csv") %>%
filter(state == "Florida") %>%
filter(county == "Miami-Dade") %>%
filter(date >="2020-06-01" )
thm <-
hc_theme(
colors = c("#025930","#F27B35","#F24405","#d4bf95","#a2ad00","#A2B1BD"),chart = list(
backgroundColor = "transparent",style = list(fontFamily = "sans-serif")
),xAxis = list(
gridlinewidth = 1
)
)
```
```{r download}
# Add download handling
output$downLink <- downloadHandler(
filename =paste0("ModelReport-",Sys.Date(),".pdf"),content = function(file) {
to_save <- list(
deaths = deaths()
)
readr::write_rds(to_save,"config_data.rds")
rmarkdown::render("report.Rmd")
#webshot::webshot("report.html",file = file)
}
)
Tab1
=====================================
Row
-------------------------------------
### Chart 1
```{r}
deaths <- hchart(mdc_c19,"line",hcaes(x = date,y = deaths)) %>%
hc_add_theme(thm)
deaths
```
### Chart 2
```{r}
```
这是报告。Rmd
---
title: "Dashboard Report"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r}
data <- readr::read_rds("config_data.RDS")
data$deaths %>% print()
```
解决方法
flexdashboard :: flexdashboard: source_code:嵌入
需要在新行的源代码之前缩进(按回车键),但是我无法使其工作。 Here's more information.
哎呀,没关系,对不起。请忽略。我看错了