我使用带有行布局的 flexdashboard 创建了一个仪表板。我的第一行包括值框,第二行是传单 map 。如何在第二行上方添加标题?
如下面的代码所示,我在第二行下使用了 ### Map
标题,但它呈现为小标题(在输出中显示)。有没有办法:
- 在两行之间添加换行符?
- 要将标题格式设置为增大字体大小并加粗?
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
smooth_scroll: true
---
<br><br><br>
```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
```
Row
-----------------------------------------------------------------------
### Articles per Day
```{r}
valueBox("5 articles", icon = "fa-pencil")
```
### Comments per Day
```{r}
valueBox("10 comments", icon = "fa-comments")
```
Row
-----------------------------------------------------------------------
### Map
```{r}
m <- leaflet() %>%
addTiles() %>%
setView(lng=-77.030137, lat=38.902986, zoom = 16) %>%
addMarkers(lng=-77.030137, lat=38.902986, popup="<b>Hello</b><br><a href='https://www.washingtonpost.com'>-Me</a>")
m
```
输出:
最佳答案
您可以增加字体大小并加粗标题### Map
,具体来说,您可以通过使用CSS类(例如.custom
)来定位它并应用.chart-title
类的 CSS 规则。
要在值框和 map 之间创建空间,一种选择是增加上边距。
---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
smooth_scroll: true
---
<br><br><br>
```{css, echo=FALSE}
.custom {
margin-top: 30px;
}
.custom .chart-title{
font-size: 30px;
font-weight: bold;
}
```
```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
```
Row
-----------------------------------------------------------------------
### Articles per Day
```{r}
valueBox("5 articles", icon = "fa-pencil")
```
### Comments per Day
```{r}
valueBox("10 comments", icon = "fa-comments")
```
Row
-----------------------------------------------------------------------
### Map {.custom}
```{r}
m <- leaflet() %>%
addTiles() %>%
setView(lng=-77.030137, lat=38.902986, zoom = 16) %>%
addMarkers(lng=-77.030137, lat=38.902986, popup="<b>Hello</b><br><a href='https://www.washingtonpost.com'>-Me</a>")
m
```
关于r - 如何添加标题和换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73788937/