我在R中用线条和散点以及填充区域变量制作了一个Plotly图 . X轴是以as.POSIXCT格式化的日期和时间,格式为“%Y-%m-%d%H:%M:%S” . 每隔10分钟就有2个月的数据 . Y轴是单位数 .
我正在将图表集成到Shiny Dashboard中 . 我想使用daterangeInput来选择X轴的日期范围 . 但是我无法弄清楚如何将daterangeInput集成为被动/交互式 .
任何帮助,将不胜感激!
The Plotly graph, consolidated:
graph <- plot_ly(master, x = date, y = arrival.one, name = 'One Arrival', visible = "legendonly") %>%
add_trace(x= date, y = arrival.two, name = 'Two Arrival', mode = 'lines', visible = "legendonly" ) %>%
layout( xaxis = list(title= "Date and Time",
rangeslider = list (type = "date")))
The UI:
ui <- dashboardPage(skin="black",
dashboardHeader(title = "Rack Filling"),
dashboardSidebar(sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("line-chart")),
menuItem("Staffing", tabName = "staffing", icon = icon("male")),
dateRangeInput("inDateRange", "Date range input:")
)),
The Server:
server <- function(input, output) {
output$graph <- renderPlotly({graph
})
output$event <- renderPrint({
??????????
1 回答
在
server
函数中,您必须创建一个响应,每次更改DateRange时都会过滤数据集 . 你称之为被动反应来绘制你的情节: