我有一个 flex 仪表板和两个我想包含的 plotly gauge 图表,但是我的自定义布局似乎不同意它们。当我使用通用布局设置时,它们工作得很好,但一旦我添加自定义布局,标题就会消失。我认为这与 plotly 可视化特别有关,因为 ggplot 图表和可反应表在过去都没有遇到过这种布局的问题。任何帮助将不胜感激!
library(flexdashboard)
library(plotly)
# Gauge 1 Code
{
fig2 <- plot_ly(
type = "indicator",
mode = "gauge+number+delta",
value = 1.1,
title = list(text = "ACWR: Total Distance", font = list(size = 32)),
gauge = list(
axis = list(range = list(NULL, 2), tickwidth = 1, tickcolor = "#522D80"),
bar = list(color = "#522D80"),
bgcolor = "white",
borderwidth = 2,
bordercolor = "gray",
steps = list(
list(range = c(0, 0.8), color = "#fffe88"),
list(range = c(0.8, 1.3), color = "#75ff68"),
list(range = c(1.5, 2), color = "#ff4444"))))
fig2 <- fig2 %>%
layout(
margin = list(l=20,r=20),
paper_bgcolor = "white",
font = list(color = "#f56600", family = "Arial"))
}
fig2
{
fig <- plot_ly(
type = "indicator",
mode = "gauge+number+delta",
value = 1.0,
title = list(text = "ACWR: Total Distance", font = list(size = 32)),
gauge = list(
axis = list(range = list(NULL, 2), tickwidth = 1, tickcolor = "#522D80"),
bar = list(color = "#522D80"),
bgcolor = "white",
borderwidth = 2,
bordercolor = "gray",
steps = list(
list(range = c(0, 0.8), color = "#fffe88"),
list(range = c(0.8, 1.3), color = "#75ff68"),
list(range = c(1.5, 2), color = "#ff4444"))))
fig <- fig %>%
layout(
margin = list(l=20,r=20),
paper_bgcolor = "white",
font = list(color = "#f56600", family = "Arial"))
}
fig
这是我的自定义布局:
title: "Lacrosse Dashboard"
output:
flexdashboard::flex_dashboard:
theme:
version: 4
bg: "#ffffff"
fg: "#FDF7F7"
primary: "#F56600"
navbar-bg: "#3ADAC6"
base_font:
google: Prompt
heading_font:
google: Sen
code_font:
google:
# arguments to sass::font_google()
family: JetBrains Mono
local: false
orientation: columns
vertical_layout: scroll