英文:
Keep current month selected in shinyWidgets::airMonthinputPicker()
问题
我正在使用shinyWidgets
包中的airMonthpickerInput()
函数。对于我的特定应用程序,起始值(月份)是2019年2月(如在value = as.Date("2019-02-01")
中定义)。在以下代码中,这将显示正确:
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
airMonthpickerInput(inputId = "select_month", label = "Select Month", value = as.Date("2019-02-01"), multiple = FALSE, autoClose = TRUE)
)
)
server <- function(input, output) {
}
app <- shinyApp(ui = ui, server = server)
runApp(app, host="0.0.0.0", port=5050, launch.browser = TRUE)
然而,当尝试更改月份时,生成的弹出窗口默认显示为_当前_月份(在撰写时为2020年1月)。大部分应用程序的数据来自2019年(因为年份已经过去),因此用户必须点击月份选择器,然后点击左箭头以显示2019年的月份,然后选择2019年内所需的月份。
我希望消除这种摩擦(过多的按钮点击),以便在点击月份选择器时,仍然突出显示2019年2月(即显示2019年,而不是2020年)。是否有可能做到这一点?我已经检查了函数的参数,但没有找到明显的可以让我在尝试更改月份时显示2019年的选项。
英文:
I am using the airMonthpickerInput()
function from the shinyWidgets
package. For my particular application, the start value (month) is February 2019 (as defined in value = as.Date("2019-02-01")
. This displays correctly, given the code below:
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
airMonthpickerInput(inputId = "select_month", label = "Select Month", value = as.Date("2019-02-01")), multiple = FALSE, autoClose = TRUE)
)
)
)
server <- function(input, output) {
}
app<-shinyApp(ui = ui, server = server)
runApp(app, host="0.0.0.0",port=5050, launch.browser = TRUE)
However, when you try to change month, the resulting popup defaults to showing the current month (at the time of writing, January 2020). Most of the application's data is from 2019 (as you'd expect seeing as the year is now over) thus users must click the month picker, then the left arrow to show 2019's months, and then select the required month within 2019.
I would like to remove this friction (excessive button clicking) so that, when clicking the month picker, February 2019 is still highlighted (i.e. 2019 is displayed, not 2020). Is it possible to do this? I have checked the function's arguments but cannot see anything obvious that will allow me to show 2019 when trying to change the month.
答案1
得分: 1
"Turns out there was a bug in shinyWidgets::airiMonthinputPicker()
. A very quick bug fix from @Victorp has resolved the issue. If anyone else is currently expericing this issue, reinstall shinyWidgets
from Github. Full details can be found here: https://github.com/dreamRs/shinyWidgets/issues/248"
英文:
Turns out there was a bug in shinyWidgets::airiMonthinputPicker()
. A very quick bug fix from @Victorp has resolved the issue. If anyone else is currently expericing this issue, reinstall shinyWidgets
from Github. Full details can be found here: https://github.com/dreamRs/shinyWidgets/issues/248
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论