【问题标题】:Custom play button for slider input in Shiny?Shiny中滑块输入的自定义播放按钮?
【发布时间】:2015-06-12 12:40:32
【问题描述】:

http://shiny.rstudio.com/reference/shiny/latest/sliderInput.html 表示您可以使用 HTML 标签或字符向量来修改滑块输入中播放按钮的外观。我希望我的播放按钮更大一点或改用图像,但我无法让它正常工作,也找不到在 Google 上使用 playButton 或 pauseButton 参数的人的示例。有什么建议吗?

添加以下作为参数:

playbutton=HTML("<img src=\"~/www/play.png\">")

给出一个未使用的参数错误

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    我知道这是一个老问题,但想添加另一种方法,因为那里没有太多信息!

    如果你只是想让播放/暂停按钮更大,你可以用 css 做到这一点。需要注意的重要一点是,它是通过更改图标的字体大小来完成的,而不是任何其他大小参数,如高度或宽度。在您的 UI 中添加这样的一行(我的是在 DashboardBody() 的开头,尽管这取决于您的应用程序的结构):

    tags$head(tags$style(type='text/css', ".slider-animate-button { font-size: 20pt !important; }"))
    

    【讨论】:

      【解决方案2】:

      playButton 不是sliderInput 的参数。相反,playButton 是animationOptions 的参数,用于sliderInput 的动画参数。

      详情请看这里: http://shiny.rstudio.com/reference/shiny/latest/sliderInput.html

      但是,我尝试以这种方式设置自定义播放按钮,但没有成功。您可能只需要自己编写滑块的 HTML,这并不难。这是带有动画控件的通用滑块的 HTML 输出:

            <div class="form-group shiny-input-container">
              <label class="control-label" for="bins">Number of bins:</label>
              <input class="js-range-slider" id="bins" data-min="1" data-max="50" data-from="30" data-step="1" data-grid="true" data-grid-num="9.8" data-grid-snap="false" data-prettify-separator="," data-keyboard="true" data-keyboard-step="2.04081632653061"/>
              <div class="slider-animate-container">
                <a href="#" class="slider-animate-button" data-target-id="bins" data-interval="1000" data-loop="FALSE">
                  <span class="play">
                    <i class="glyphicon glyphicon-play"></i>
                  </span>
                  <span class="pause">
                    <i class="glyphicon glyphicon-pause"></i>
                  </span>
                </a>
              </div>
            </div>
      

      您可以编辑播放/暂停部分的 HTML,以查看您喜欢的方式以及滑块的各种参数。

      【讨论】:

      • 字。谢谢,我没有仔细阅读文档
      • 您对如何将原始 HTML 集成到闪亮的 r 代码中有何建议?
      • 取 HTML 代码,在 span 标签之间添加你的 img 代码,粘贴到 R 中,用单引号 (" -> ') 切换所有引号,然后引用整个内容并设置为字符。然后,使用 HTML 函数将其添加到您的 UI.r 中。这应该让您足够接近,其余的应该可以通过一些修补来修复。
      猜你喜欢
      • 1970-01-01
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多