## in server.r
output$null_plot <- renderDygraph({
## don't output anything unless you have the data ready
validate(
need(casualImpactData(), "Model Working")
)
## the data for the plot is in here
ci <- casualImpactData()$series
## get the start and end from the user input in ui.r
start <- input$range_date[1]
end <- input$range_date[2]
## we need to convert the dataframe into a timeseries for dygraph
orderme <- seq(as.Date(start), as.Date(end), by=1)
ci <- xts(ci, orderme)
## the dygraph output
dygraph(data=ci[,c('response', 'point.pred', 'point.pred.lower', 'point.pred.upper')],
main="Expected (95% confidence level) vs Observed", group="ci") %>%
dyRangeSelector(dateWindow = c(input$event_date - 7, input$range_date[2])) %>%
dyEvent(date = input$event_date, "Event") %>%
dySeries(c('point.pred.lower', 'point.pred','point.pred.upper'), label='Expected') %>%
dySeries('response', label="Observed")
})