保持 shinyWidgets::airMonthinputPicker() 中选择的当前月份。

huangapple go评论82阅读模式
英文:

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(&quot;2019-02-01&quot;). This displays correctly, given the code below:

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui &lt;- dashboardPage(
  dashboardHeader(title = &quot;Basic dashboard&quot;),
  dashboardSidebar(),
  dashboardBody(
  
             airMonthpickerInput(inputId = &quot;select_month&quot;, label = &quot;Select Month&quot;, value = as.Date(&quot;2019-02-01&quot;)), multiple = FALSE, autoClose = TRUE)
    
  )
)
)

server &lt;- function(input, output) {
  
  
}

app&lt;-shinyApp(ui = ui, server = server)
runApp(app, host=&quot;0.0.0.0&quot;,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

huangapple
  • 本文由 发表于 2020年1月3日 22:45:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580548.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定