R 闪亮滑块输入显示时间 [英] R shiny sliderInput show time
问题描述
我有一个与 R Shiny 中的滑块输入相关的问题.在sliderInput 中,值是一个数字.一些例子表明数字是 $number.但是,如果我想将sliderInput的值显示为时间,比如10:00、15:00,我该怎么做?非常感谢.
I have a question related to the sliderInput in R shiny. In the sliderInput, the value is a number. Some examples show that the number is $number. However, if I want to show the value of sliderInput as a time, say 10:00, 15:00, how should I do it? Thanks a lot.
推荐答案
这是部分答案,为您提供一些具有一定 JS 知识的人可以使用的提示.据我所知,从 Shiny-0.5 开始,您只能通过编写一些 Javascript/JQuery 来实现这一点.
This is a partial answer, giving you some pointers that anyone with some JS knowledge can use. To the best of my knowledge, as of Shiny-0.5, you can achieve this only by writing some Javascript/JQuery.
如果您能够将 JQuery 插件合并到您的 UI.R Shiny 应用程序中,这个链接 有你想要的.
If you are able to incorporate JQuery plug-ins into your UI.R Shiny app, this link has what you want.
使用 CSS 样式确保
SliderInput
标签按照您想要的方式进行格式化.(显示日期/时间而不是数字.)我通常将任何tags$head()
样式代码放在SideBarPanel()
中,并且它起作用了.
Use CSS style to make sure that the
SliderInput
labels get formatted the way you want. (Showing Date/Time as opposed to numbers.) I typically put anytags$head()
styling code insideSideBarPanel()
and it has worked.
您还需要一个 Javascript 函数,它接受 input$number
并返回一个有效的日期/时间.代码链接: 这篇 JQuery 帖子 有一个你应该可以使用的 javascript 函数(使用 DatePicker)
You will also need a Javascript function that takes in the input$number
and returns a valid date/time. Link with code: This JQuery post has a javascript function that you should be able use (with DatePicker)
希望有所帮助.
这篇关于R 闪亮滑块输入显示时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!