I am new to shiny. I would like to give static color for the slider bar irrespective of the range selected in shiny dashboard. I want to have different color for slider as follows, Ex: 0 to 40 – red, 40 to 60 – blue, 60 to 100 – green. Please help me solve this issue. My code,
library(shiny)
library(shinydashboard)
ui <- dashboardPage(skin = "black",
dashboardHeader(title = "test"),
dashboardSidebar(
sidebarMenu(
menuItem("Complete", tabName = "comp"))),
dashboardBody(
tabItems(
tabItem(tabName = "comp",
fluidRow(
sliderInput("range_var", "", value = c(90,100), min = 0, max = 100, width = '200%'))))))
server <- function(input, output, session) {
observe({
updateSliderInput(session, "range_var", label = "", value = c(90, 100), min = 0, max = 100)
})
}
shinyApp(ui, server)
Thanks Balaji
Oh, then i misinterpreted your question. You can achieve this also by using css-commands and correct selectors:
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <- dashboardPage(skin = "black",
dashboardHeader(title = "test"),
dashboardSidebar(
sidebarMenu(
menuItem("Complete", tabName = "comp"))),
dashboardBody(
inlineCSS(".irs-line-left { background-color: red; width: 40%;}
.irs-line-mid { background-color: blue; width: 20%; left: 40%;}
.irs-line-right { background-color: green; width: 40%; left: 60%;}
"
),
shinyjs::useShinyjs(),
tabItems(
tabItem(tabName = "comp",
fluidRow(
sliderInput("range_var", "", value = c(90,100), min = 0, max = 100, width = '200%'))))))
server <- function(input, output, session) {
}
shinyApp(ui, server)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With