r - 闪亮:无法向我的值框添加颜色、图标或字幕
问题描述
我使用我构建了我的第一个仪表板,shiny
并且我想添加一些值框,但是当我这样做时,值框出现时没有颜色、字幕或图标。
我无法弄清楚错误是什么。请提前帮助和感谢。
这是我写的代码:
library(shiny)
library(shinydashboard)
library(flexdashboard)
library(readxl)
Base_Ferias <- read_excel("C:/Users/tomas/Desktop/R/Apps/Seguimiento_ferias/Base_Avance_Ferias.xlsx")
Base_Ferias$T_respuesta <- as.numeric(Base_Ferias$T_respuesta)
ui <-dashboardPage(skin = "red",
dashboardHeader(title = "My Dashboard", titleWidth = 450),
dashboardSidebar(selectInput("actividad", "Select",
choices = Base_Ferias$Actividad)),
dashboardBody(
box(flexdashboard::gaugeOutput("chart"),width=200,
title="Percentage"),
box(valueBoxOutput("value1"), height = "100px", width = 3)
)
)
server <- shinyServer(function(input, output, session) {
output$chart <- flexdashboard::renderGauge({
x <- Base_Ferias[Base_Ferias$Actividad==input$actividad,]
y <- x$T_respuesta
gauge(y, min = 0, max = 100, symbol = '%')
})
output$value1 <- renderValueBox({
valueBox(
paste0(25,"%"), "subtitle",icon("stats",lib='glyphicon'),
color = "purple")
})
})
shinyApp(ui = ui, server = server)
解决方案
从 .附加flexdashboard
具有相同名称的最后一个掩码函数shinydashboard
。使用valueBox
fromshinydashboard
代替:
library(shiny)
library(shinydashboard)
#>
#> Attaching package: 'shinydashboard'
#> The following object is masked from 'package:graphics':
#>
#> box
ui <-dashboardPage(skin = "red",
dashboardHeader(title = "My Dashboard", titleWidth = 450),
dashboardSidebar(selectInput("actividad", "Select",
choices = c("one", "two"))),
dashboardBody(
box(flexdashboard::gaugeOutput("chart"),width=200,
title="Percentage"),
box(valueBoxOutput(outputId = "value1"))
)
)
server <- shinyServer(function(input, output, session) {
output$chart <- flexdashboard::renderGauge({
x <- 1
y <- 10
flexdashboard::gauge(y, min = 0, max = 100, symbol = '%')
})
output$value1 <- renderValueBox({
valueBox(
paste0(25,"%"), "subtitle",icon("stats",lib='glyphicon'),
color = "purple")
})
})
shinyApp(ui = ui, server = server)
#>
#> Listening on http://127.0.0.1:5809
由reprex 包(v0.3.0)于 2020 年 3 月 4 日创建
推荐阅读
- javascript - 遍历数组时不断变得未定义
- html - 如何修复 Bootstrap 中的下拉黎明按钮
- angular - 在角度数据表中实现服务器端分页
- javascript - How do I set a value as a string React-Native?
- react-native - 程序在浏览器中显示正常但无法在电子窗口中加载资源
- reactjs - 使用 redux 将对象添加到数组
- xamarin.forms - 从 xamarin 表单中的视图模型导航
- html - 如何使用嵌入
- javascript - 如何从父母更新孩子的(从创建的列表中)道具
- c++ - 使用 Media Foundation 对通过桌面复制获得的 D3D 表面进行编码