mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-02 02:34:57 -05:00
basic shim for sliders example
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
## (Under Construction)
|
||||

|
||||
|
||||
The Sliders application demonstrates the many capabilities of slider controls, including the ability to run an animation sequence. To run the example type:
|
||||
|
||||
@@ -12,14 +11,80 @@ The Sliders application demonstrates the many capabilities of slider controls, i
|
||||
|
||||
<pre><code class="r">library(shiny)
|
||||
|
||||
# Define UI for slider demo application
|
||||
shinyUI(pageWithSidebar(
|
||||
|
||||
# Application title
|
||||
headerPanel("Sliders"),
|
||||
|
||||
# Sidebar with sliders that demonstrate various available options
|
||||
sidebarPanel(
|
||||
# Simple integer interval
|
||||
sliderInput("integer", "Integer:",
|
||||
min=0, max=1000, value=500),
|
||||
|
||||
# Decimal interval with step value
|
||||
sliderInput("decimal", "Decimal:",
|
||||
min = 0, max = 1, value = 0.5, step= 0.1),
|
||||
|
||||
# Specification of range within an interval
|
||||
sliderInput("range", "Range:",
|
||||
min = 1, max = 1000, value = c(200,500)),
|
||||
|
||||
# Provide a custom currency format for value display
|
||||
sliderInput("format", "Custom Format:",
|
||||
min = 0, max = 100000, value = 50000, step = 25000,
|
||||
format="$#,##0", locale="us"),
|
||||
|
||||
# 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.")
|
||||
),
|
||||
|
||||
# Show a table summarizing the values entered
|
||||
mainPanel(
|
||||
tableOutput("values")
|
||||
)
|
||||
))
|
||||
</code></pre>
|
||||
|
||||
#### server.R
|
||||
|
||||
<pre><code class="r">library(shiny)
|
||||
|
||||
# Define server logic for slider examples
|
||||
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",
|
||||
"Decimal",
|
||||
"Range",
|
||||
"Custom Format",
|
||||
"Animation"),
|
||||
Value = c(printValue(input$integer),
|
||||
printValue(input$decimal),
|
||||
printValue(input$range),
|
||||
printValue(input$format),
|
||||
printValue(input$animation)),
|
||||
stringsAsFactors=FALSE)
|
||||
})
|
||||
|
||||
# Show the values using an HTML table
|
||||
output$values <- reactiveTable(function() {
|
||||
sliderValues()
|
||||
})
|
||||
})
|
||||
</code></pre>
|
||||
|
||||
|
||||
|
||||
BIN
tutorial/screenshots/sliders.png
Normal file
BIN
tutorial/screenshots/sliders.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Reference in New Issue
Block a user