我的选择框小部件中有3个数据源。当我从应用程序的选择框中选择不同的数据源时,我正在尝试更新图形。但是,当我更改数据源时,图表不会更新。我是否需要使用reactive
命令?
shinyUI(fluidPage(
# Application title
titlePanel("Temperature Data"),
sidebarLayout(
sidebarPanel(
selectInput("dataSelection", label = "Choose a Data Set", choices = c("Dataset 1", "Dataset 2")),
selectInput("component1", label = "Choose a Chart",
choices = c("Watts"),
selected = "Watts" )),
mainPanel(
dygraphOutput("TempRise")
)
)
#server.r
shinyServer(function(input, output) {
output$TempRise <- renderDygraph({
dataSource <- switch(input$dataSelection,
"Dataset 1" = Data1,
"Dataset 2" = Data2)
TempData <- switch(input$component1,
"Watts" = dataSource$Watts)
dygraph(TempData, main = "Temperature Data") %>%
dyRangeSelector()
})
})