mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-29 03:00:45 -04:00
new slider example code
This commit is contained in:
@@ -41,16 +41,14 @@ shinyUI(pageWithSidebar(
|
||||
sliderInput("range", "Range:",
|
||||
min = 1, max = 1000, value = c(200,500)),
|
||||
|
||||
# Provide a custom currency format for value display
|
||||
# Provide a custom currency format for value display, with basic animation
|
||||
sliderInput("format", "Custom Format:",
|
||||
min = 0, max = 100000, value = 50000, step = 25000,
|
||||
format="$#,##0", locale="us"),
|
||||
min = 0, max = 10000, value = 0, step = 2500,
|
||||
format="$#,##0", locale="us", animate=TRUE),
|
||||
|
||||
# Animation with custom interval (in milliseconds) to control speed
|
||||
# (also provide helpText to highlight the possiblity of animation)
|
||||
sliderInput("animation", "Animation:", 1, 2000, 1, step = 10,
|
||||
animationInterval = 300),
|
||||
helpText("Use the Play button to animate values.")
|
||||
# Animation with custom interval (in ms) to control speed, plus looping
|
||||
sliderInput("animation", "Looping Animation:", 1, 2000, 1, step = 10,
|
||||
animate=animationOptions(interval=300, loop=T))
|
||||
),
|
||||
|
||||
# Show a table summarizing the values entered
|
||||
@@ -74,11 +72,6 @@ shinyServer(function(input, output) {
|
||||
# Reactive function to compose a data frame containing all of the values
|
||||
sliderValues <- reactive(function() {
|
||||
|
||||
# Show values using R's default print format
|
||||
printValue <- function(value) {
|
||||
capture.output(print(value))
|
||||
}
|
||||
|
||||
# Compose data frame
|
||||
data.frame(
|
||||
Name = c("Integer",
|
||||
@@ -86,11 +79,11 @@ shinyServer(function(input, output) {
|
||||
"Range",
|
||||
"Custom Format",
|
||||
"Animation"),
|
||||
Value = c(printValue(input$integer),
|
||||
printValue(input$decimal),
|
||||
printValue(input$range),
|
||||
printValue(input$format),
|
||||
printValue(input$animation)),
|
||||
Value = as.character(c(input$integer,
|
||||
input$decimal,
|
||||
paste(input$range, collapse=' '),
|
||||
input$format,
|
||||
input$animation)),
|
||||
stringsAsFactors=FALSE)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user