[英]Removing/hiding minor ticks of a sliderInput in Shiny
我希望從sliderInput()
刪除/隱藏次要刻度(不是主刻度sliderInput()
。 例如,在Shiny app - Old Faithful Geyser Data的默認示例中,有一個sliderInput()
可以為直方圖選擇多個bin。 箱數總是整數。 因此,最好在sliderInput()
隱藏/刪除次要刻度,並僅顯示bin編號的主要刻度。
Shiny app的默認示例:
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 10,
value = 1)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)
我在sliderInput()
嘗試了tick = FALSE
,如下所示:
sliderInput("bins",
label = "Number of bins:",
min = 1,
max = 10,
value = 1,
ticks = FALSE)
但是,這會從sliderInput()
刪除所有刻度(包括主刻度sliderInput()
。
感謝先進的所有幫助。
您可以使用tags$style(type = "text/css", ".irs-grid-pol.small {height: 0px;}")
覆蓋CSS。 CSS可以在這里找到: https : //github.com/IonDen/ion.rangeSlider/issues/171 。
生成的sliderInput()
僅顯示整數的刻度:
shinyApp(
ui <- fluidPage(
tags$style(type = "text/css", ".irs-grid-pol.small {height: 0px;}"),
sliderInput("bins", "Number of bins:", 1, 10, 1)
),
server <- function(input, output) {}
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.