我的主面板中有一张传单地图,我想在 R 闪亮应用程序中的 absolutePanel 中放置一个 dygraph。我的问题是我在 absolutePanel 中看不到 dygraph。
我的 ui.R 中的代码是这样的:
library(dygraphs)
absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
draggable = TRUE, top = 60, left = "auto", right = 20, bottom = "auto",
width = 300, height = "auto",
h2("Sensitivity Explorer"),
sliderInput(inputId="year",
label="Select a forecast year",
value=2018, min=2018, max=2050),
numericInput("months", label = "Months to Predict",
value = 72, min = 12, max = 144, step = 12),
selectInput("interval", label = "Prediction Interval",
choices = c("0.80", "0.90", "0.95", "0.99"),
selected = "0.95"),
checkboxInput("showgrid", label = "Show Grid", value = TRUE),
dygraphOutput("dygraph",width = '50%')
)
和我的 server.R :
library(dygraphs)
function(input, output, session) {
predicted <- reactive({
hw <- HoltWinters(ldeaths)
predict(hw, n.ahead = input$months,
prediction.interval = TRUE,
level = as.numeric(input$interval))
})
output$dyngraph <- renderDygraph({
if (nrow(zipsInBounds()) == 0)
return(NULL)
dygraph(predicted(), main = "Predicted Deaths/Month") %>%
dySeries(c("lwr", "fit", "upr"), label = "Deaths") %>%
dyOptions(drawGrid = input$showgrid)
})
}