rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
893 stars 298 forks source link

infoBox() width parameter is stuck on value of 4 #262

Open ghost opened 6 years ago

ghost commented 6 years ago

infoBox() width parameter stays 4 regardless of the value specified in a function call. For example I want to set width to 6, but I still get 4. Below are the function call and the generated HTML:

infoBox( dtSub$company , dtSub$text , href = dtSub$link , icon = icon("briefcase") , width = 6 )

<div class="shiny-html-output col-sm-4 shiny-bound-output" id="ibox1"><a href="http://abbvie.jobs/lake-county-il/senior-manager-statistical-programming/FB51233B2DFF4AE38BE6A9A2A4B794FA/job/">
  <div class="info-box">
    <span class="info-box-icon bg-aqua">
      <i class="fa fa-briefcase"></i>
    </span>
    <div class="info-box-content">
      <span class="info-box-text">AbbVie Inc.</span>
      <span class="info-box-number">Senior Manager, Statistical Programming</span>
      <p> Lake County . . . Illinois, Retrieved 3 day(s) ago</p>
    </div>
  </div>
</a></div>
wch commented 6 years ago

Can you supply a reproducible example? When I run this, the width gets set correctly:

> infoBox("a", "b", width=1)
<div class="col-sm-1">
  <div class="info-box">
    <span class="info-box-icon bg-aqua">
      <i class="fa fa-bar-chart"></i>
    </span>
    <div class="info-box-content">
      <span class="info-box-text">a</span>
      <span class="info-box-number">b</span>
    </div>
  </div>
</div>

It looks like you might be using renderUI?

ghost commented 6 years ago

You are absolutely right Winston, I am using renderInfoBox since I need to programmatically populate title, value, subtitle and href. Moreover I also loop over the renderInfoBox to create many boxes. Below is MWE and the generated HTML (the div section). As you can see the class has ''col-sm-4' Thank you so much for the awesome shinydashboard package and your time helping with this.

R

library(shiny)
library(shinydashboard)

server <- function(input, output) {
  output$test <- renderInfoBox({
    infoBox(
      'company'
      , 'text'
      , 'location'
      , href = 'https://www.rstudio.com/'
      , width = 6
    )
  })

}

body <- dashboardBody(
  infoBoxOutput(outputId = 'test')
)

ui <- dashboardPage(
  dashboardHeader(disable = TRUE),
  dashboardSidebar(disable = TRUE),
  body
)

shinyApp(ui, server)

HTML

<div class="shiny-html-output col-sm-4 shiny-bound-output" id="test"><a href="https://www.rstudio.com/">
  <div class="info-box">
    <span class="info-box-icon bg-aqua">
      <i class="fa fa-bar-chart"></i>
    </span>
    <div class="info-box-content">
      <span class="info-box-text">company</span>
      <span class="info-box-number">text</span>
      <p>location</p>
    </div>
  </div>
</a></div>
AzlinII commented 6 years ago

I don't think this is fixed yet but I have found a work around for anyone who still has an issue with this. Instead of using renderInfoBox and infoBoxOutput, I used renderUI and uiOutput and that worked for me. This makes me think there is an issue with the renderInfoBox function.

clbenoit commented 3 years ago

Got same issue here