Giter VIP home page Giter VIP logo

shinybs's Introduction

shinyBS

shinyBS is a package that adds several additional Twitter Boostrap components to shiny. In January RStudio updated shiny to work with Bootstrap3 which completely broke the original shinyBS. I have updated shinyBS to work with the newest versions of shiny.

After several rounds of revisions, shinyBS v0.61 was accepted by CRAN on March 31st, 2015 and is available for install with install.packages()

install.packages("shinyBS")

Not all functionality that was in the previous versions was kept in this new version. Partly because of time constraints and partly because of some functionality being removed from Bootstrap.

Features that remain in shinyBS 0.61 include:

  • Alerts
  • Tooltips
  • Popovers
  • Modal Windows
  • Collapse Panels
  • Button upgrades

Features that are not included in shinyBS 0.61 include:

  • Navbars and related components
  • Typeaheads
  • Progress Bars
  • Button Groups
  • Table Formatting

Now that this version has been been accepted by CRAN I will start working on updates and added functionality. If you have a request please open an issue and let me know. Thanks!

shinybs's People

Contributors

baileyeiu avatar ebailey78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shinybs's Issues

constructing buttons via renderUI

Hi,

is it possible to render a set of buttons via renderUI? In Shiny various inputs can be placed in a list which then can be passed in a single return to renderUI. Via this construction one can dynamically construct e.g. a large set of slider controls based on some data values.

With shinyBS the buttons indeed show up, however, they do no longer work properly. Is this correct? If so, is there an alternative way to dynamically generate shinyBS related buttons?

For instance, this doesn't work:

   output$Test <- renderUI({
     list(bsButton("btn1", label = "Left", value = "left"), 
         bsButton("btn2", label = "Middle", value = "middle"), 
         bsButton("btn3", label = "Right", value = "right")
    )
   })

kind regards, Herman

Popover stops responding after user interaction with element

Hi again, Eric!

I'm seeing another case of odd popover behavior.

When you initially interact with a popover, it works fine. However, if you interact with the element the popover is attached to (e.g., select a choice in a radioButtons element), the popover stops responding. This doesn't always happen on the first few interactions but it does always seem to happen fairly quickly.

This can be observed using the same example I used in my last issue.

popover works

library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("x_axis_choice", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("x_axis_choice",
                                 title = "Variable Definitions.",
                                 content = "<p> So many puppies! How do they make me feel? <br> I heart them. SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY much. </p>",
                                 trigger = "click",
                                 placement = "bottom")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

Modals within DataTable

Is it possible to use a shinyBS Modal from within DataTable content? I haven't been able to figure it out on my own, or find an example to work from.

I'm using Shiny Dashboard and the DT package.

Below is some example code, where a column has been hyperlinked within the DataTable to show a simple JS Alert. Ideally I'd like to replace this alert with a lovely shinyBS Modal.

library("shiny")
library("shinydashboard")
library("datasets")
library("DT")

header <- dashboardHeader()

sidebar <- dashboardSidebar()

body <- dashboardBody(
  DT::dataTableOutput("mtcarsTable")
)

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) {

    mtcarsLinked <- reactive({

      mtcars$mpg <- sapply(datasets::mtcars$mpg, function(x) paste0('<a href="#" onclick="alert(\'Hello World\');">',x,'</a>'))

      return(mtcars)

    })

    output$mtcarsTable <- DT::renderDataTable({
      DT::datatable(mtcarsLinked(), 
                    class = 'compact',
                    escape = FALSE
      )
  })
  }
)

Table dissappears when I try change color by using highlightCells()

When I try to use function highlightCells() table dissappears.
Other people seems to have similar problems: https://groups.google.com/forum/#!msg/shiny-discuss/PvlrXLEo0z8/uQDUdFdviKMJ
Example code:

library(shinyBS)
runApp(

list(ui = bootstrapPage(pageWithSidebar(
headerPanel("Data frame with colors"),
sidebarPanel(),
mainPanel(
tableOutput("my_dataframe")
)
)
)
,
server = function(input, output, session) {

output$my_dataframe <- renderTable({ 
  data.frame("Brand ID"=1:4,"Client1"=c("red", "green", "green", "green"),
             "Client2"=c("green", "red", "green", "red")) 
    highlightCells(session, 'my_dataframe', class="error", regex = "red")

})

}
)
)

A bsNavBar page with tabPanels possible?

Hi,

first of all, I really like the shinyBS widgets, thanks a lot for creating the package. I wonder if there is a simple way to implement with bsNavBar a standard shiny navbarPage with different tabPanels, like

navbarPage("App Title",
  tabPanel("Plot"),
  tabPanel("Summary"),
  tabPanel("Table")
)

The advantage of using bsNavBar over the standard shiny navbarPage, would be that one can fix it at the top of the window. It would also be great if one could update with code the current page that is shown. Do you think this could be easily added to shinyBS?

accept width parameter in bsModal?

Hi,

It seems the default "large" size is not wide enough to host a datatable with a couple columns, it is possible to allow x-large or configurable width in this bsModal function?

bsTooltip issues with Shiny 0.11 and shinyBS 0.50

Noticing 2 issues with bsTooltip with the latest upgrades:

  1. For selectInput, if selectize is set to "true", then the tooltip will not show. Turning selectize to "false" makes the tooltip appear.
  2. If position is set to "right", tooltip box is very narrow. Any other position (top, left, bottom) and a wider box is created.

Collapse Panel defaults to closed regardless

I want a single collapse panel, defaulting to open.

  bsCollapse(multiple = FALSE, open = "filters", id = "filterBar",
             bsCollapsePanel("Data Filter", "Cell treachery spearwife night's watch, tower suckling ...", id="filters", value="1"))

It loads but by default it's closed and the user must open it

bsModal Size Options

Could the dimensions be specified in absolute size, such as pixels ? Currently, small and large are the only two settings available to users.

bsTypeAhead fails on apostrophe in choices

Surprisingly bsNavbarTypeAhead works. Tested shiny and shinyBS from Github as of today.

library(shiny)
library(shinyBS)
runApp(
  list(
    ui = bootstrapPage(
      uiOutput("bsTypeAhead"),
      textOutput("typeAheadOutput"),
      uiOutput("bsNavTypeAhead"),
      textOutput("navTypeAheadOutput")

        ),
    server = function(input, output, session) {

      output$bsTypeAhead <- renderUI({
        bsTypeAhead(inputId = "typeAhead", label = "TypAhead brocken", choices = c("O’Toole", "O'Hara"))    
      })
       output$typeAheadOutput <- renderText(input$typeAhead);

      output$bsNavTypeAhead <- renderUI({
        bsNavTypeAhead(inputId = "navtypeAhead", label = "NavTypAhead works", choices = c("O’Toole", "O'Hara"))    
      })
      output$navTypeAheadOutput <- renderText(input$navtypeAhead);
    }

    )
  )

Width of popOver with placement="right"

I added popOvers for two graphs located within the same shiny tabPanel. The popOver with placement specified as "left" shows up fine; however the width of the popOver with placement specified as "right" is too narrow making the popOver look odd as shown in the image below. This only happens for placement="right". If I used the same code and just change "right" to any other placement option, the popOver looks fine.

I can't share the entire code, but basically I just used:

 bsPopover("visid1",,title='<font size="4">Gene Expression Heatmap',content='Text to go into the popOver showing to the right of visual 1', placement="right",trigger="hover"),
 bsPopover("visid2",title='<font size="4">Gene Expression Heatmap',content='Text to go into the popOver showing to the left of visual 2', placement="left",trigger="hover"),

image

Update the UI Elements in the Modal

I have a modal linked to a text object element for printing an error message and a plot object for showing a graph. I'd like to only show one of them at a time on the modal. If I specify both of them, they both appear in the modal. It would be desirable if, in server.R, users could add and remove items from the modal, because.

bsModal Integration with DT Events

I would like to propose that bsModal can be associated with a data table. Currently, the trigger parameter requires "The id of a button or link". In my use case, I have a table of numbers, and when a cell of the table is clicked, a popup will show the scatterplot of the data used to calculate that number. I need to link the modal popup to the click information available from DT.

ShinyBS Modal is not working when I include bootstrap.css file

Hi,

I am trying to use ShinyBS’s Modal control, but it does not work for me. When I have created an example exactly same as mentioned on the website it worked fine. I noticed that when I comment theme = "bootstrap.css" in my code it works fine. Can you please explain me why it does not work with a bootstrap file included in my code? And how can I get it working, as I need to keep my version of bootstrap.css file.

Regards,
Manali

bsCollapsePanel's title argument shows a warning when handling a list

I'm trying to add an image to the title of a bsCollapsePanel with the following code:

bsCollapsePanel(
    style = "info",
    title = list(img(src = "add-button-16px.png"),
                 "Add file"),
    fileInput("data.file", "Choose a file")
)

The code works fine, but it shows two warnings probably related to the title argument:

Warning in if (getAttribs(panels[[i]])$value %in% open) { :
  the condition has length > 1 and only the first element will be used
Warning in if (!is.na(attribValue)) { :
  the condition has length > 1 and only the first element will be used

This is the result (which seems to be working with no problems):
screen shot 2015-09-28 at 13 51 57

Possible solution: The title argument could be replaced by an id argument (the identifier of the panel) and a display argument (which would be what's really shown).

testing

Hi Eric,

in my work I've extensively used shinyBS. We recently stopped using it due to the bootstrap 3 migration of Shiny by RStudio. If you need help testing the new bootstrap 3 version just let me know!

best Herman

suggestion: use display.mode = "showcase" in the examples

Hi Eric,

while I was running through the shinyBS v5.0 code I thought it would be nice if the examples used:

    runApp("example",display.mode = "showcase")

now the users can see what you are able to do, but they cannot see all the code (at least not always directly). With showcase mode that is solved.

best Herman

odd popover behavior if element names overlap with shiny namespace

Sorry, Eric, I appear to be on a quest to discover all the popover bugs.

If I assign a popover to an element and the name of that element partially overlaps with an active feature of another element... crazy stuff happens.

Specifically, observe what happens as you try to trigger the popovers for x_axis_choice2,
x_axis_choice3, and x_axis_choice4. The popovers for x_axis_choice2 and x_axis_choice3 end up actually assigned the first element's second and third radio buttons.

x_axis_choice4 does not, presumably because the first element has no fourth radio button.

library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("x_axis_choice", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("x_axis_choice",
                                 title = "VD1",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       radioButtons("x_axis_choice2", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("x_axis_choice2",
                                 title = "VD2",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right"),

                       sliderInput("x_axis_choice3", label = h4("Select X-Axis"), 
                                    min = 0, max = 100, value = 50),

                       bsPopover("x_axis_choice3",
                                 title = "VD3",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       sliderInput("x_axis_choice4", label = h4("Select X-Axis"), 
                                   min = 0, max = 100, value = 50),

                       bsPopover("x_axis_choice4",
                                 title = "VD4",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

As you might expect, one way to address this is to simply remove the number from the end of the element name (e.g., x_axis_choice instead of x_axis_choice1). Here's an example with all the problematic element names removed. The odd behavior is gone.

library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("a", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("a",
                                 title = "VD1",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       radioButtons("b", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("b",
                                 title = "VD2",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right"),

                       sliderInput("c", label = h4("Select X-Axis"), 
                                    min = 0, max = 100, value = 50),

                       bsPopover("c",
                                 title = "VD3",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       sliderInput("d", label = h4("Select X-Axis"), 
                                   min = 0, max = 100, value = 50),

                       bsPopover("d",
                                 title = "VD4",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

However, I suspect this points to a deeper issue given that users are likely to be unaware of what parts of the shiny namespace should be avoided when naming elements.

bsPopover HTML content

Hi,

Thank you for your work.

I encountered an issue with HTML content which seems to be escaped in the bsPopover function, see

bsPopover("linkID", title="title", content="<b>Test</b>")

which results in

<script>
$(document).ready(function() {
    setTimeout(function() {shinyBS.addTooltip('linkID', 'popover', 
    {'content': '&lt;b&gt;Test&lt;/b&gt;', 'placement': 'bottom', 'trigger': 'hover', 'title': 'title'}
    )}, 100) });
</script> 

Directly masking HTML does not work, either:

content=HTML("<b>Test</b>")

My current workaround is replacing the JavaScript code manually:

bsPopoverTag <- bsPopover("linkID", title="title", content="<b>Test</b>")
bsPopoverHTML <- HTML("$(document).ready(function() {setTimeout(function() { shinyBS.addTooltip('linkID', 'popover', {'content': '<b>Test</b>', 'placement': 'bottom', 'trigger': 'hover', 'title': 'title'})}, 100)});")
bsPopoverTag$children[[1]] <- bsPopoverHTML

Thanks
Alex

Bug: ConditionalPanel within a CollapsePanel confuses the collapsePanel

I have a nested conditionalPanel within a bsCollapse. When the conditionalPanel hits a FALSE condition and elements are hidden, the value of the bsCollapsePanel does not get returned properly. That is, when you try to ask which panel is open, you will get NULL (which is wrong). If you go back and forth between the conditions, you see that the values get added to a list for some reason.

So you get NULL and then ["thePanel", "thePanel"]

(behavior should be clear if you check with what I have below)

ui

shinyUI(fluidPage(bsCollapse(
      id = "theCollapse",
      bsCollapsePanel(title = "thePanel",
                      selectInput(inputId = "selectId", label = "label", choices = c(a= 'a', b='b')),
                      conditionalPanel(condition = "input.selectId == 'b'",
                                       selectInput(inputId = "condId", label = "label2", choices = c('d', 'e'))))))))

server

shinyServer(function(input, output) {
observe({
  x <- reactive({input$theCollapse})
  print(paste(x()))

Unless I'm mistaken, this is truly a bug. Let me know if I can be of any help here; this is a pretty big blocker for my project. Thanks!

addPopover Doesn't Work for datatable Object

I have a data table created using the DT package.

output[["scoresTable"]] <- DT::renderDataTable(datatable(aTable))

When I create a popover for it, nothing appears and there are no errors in the R console.

addPopover(session, "scoresTable", "Data", content = "<p>Waiting time</p>")

Also, may the documentation be more specific about what content the popover can show ? I was thinking about clicking a cell in a table and drawing a scatterplot in the popover. Is it limited to showing text ?

behavior change request: limit element regions that trigger popover

Currently, the region of an element that can be interacted with to trigger a popover seem to be inconsistent. It appears to vary both by element type and trigger type.

For example, here is an example with two kinds of shiny elements (radioButtons v. inputSliders) with two kinds of popover triggers (click v. hover).

The popover for each element behaves differently. In the order the elements are presented, the popover responds to interactions with...

  1. any part of the non-input region (i.e., anywhere but the choice buttons)
  2. any region
  3. a specific feature of the input region (i.e., only the slider knob; not to clicks on the slider bar or non-input regions)
  4. any part of the input region (but not non-input regions, such as the label)
library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("a", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("a",
                                 title = "VD1",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       radioButtons("b", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("b",
                                 title = "VD2",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right"),

                       sliderInput("c", label = h4("Select X-Axis"), 
                                    min = 0, max = 100, value = 50),

                       bsPopover("c",
                                 title = "VD3",
                                 content = "STUFF",
                                 trigger = "click",
                                 placement = "right"),

                       sliderInput("d", label = h4("Select X-Axis"), 
                                   min = 0, max = 100, value = 50),

                       bsPopover("d",
                                 title = "VD4",
                                 content = "STUFF",
                                 trigger = "hover",
                                 placement = "right")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

It would be nice if popover response was consistent across element types and trigger types.

I think having the popover occur only during interactions with non-input regions makes the most sense (as otherwise users may have to engage inputs to see desired information). But I'm biased by my project needs. 😄

Alternatively, allowing us to choose something like trigger_region would work great too...

Thanks again for your work and patience, Eric!!

Close.button ID

Is there a way to access it? On closing the modal I wish to discard changes as default and display a shinyAlert.
Thank you!

Popup window cannot be opened

I have added a popup window in my app with "bsModal" and "toggleModal" function but cannot open it by now.
Error as follows:
Error in (structure(function (input, output, session) :
could not find function "toggleModal"

bsTypeAhead for shiny 0.11

Hi, I've been using your bsTypeAhead function before and it's really great. However I can't find it in a new release. Are you planning to add it and make it work with latest version of shiny?
Thank you

Button Group Feature

The button group feature was extremely useful to aid in structuring shiny apps. If there is any way to add this back in, that would be awesome.

Tooltip bug?

Thanks for the great work!

I've noticed strange behavior with tooltips in the shinyBS3 branch and I can't quite figure out what's going on. I've tried to recreate the problem with a minimal example:

Below is the bsCollapse example you provide (copied verbatim) but with two added action buttons with tooltips. When I run this app only the "test2" tooltip renders. The only difference between the two is that one action button has been added via renderUI and the other directly in the ui.

app <- shinyApp(
  ui = 
    fluidPage(
      sidebarLayout(
        sidebarPanel(HTML("This button will open Panel 1 using <code>updateCollapse</code>."), 
                     actionButton("p1Button", "Push Me!"),
                     selectInput("styleSelect", "Select style for Panel 1", 
                                 c("default", "primary", "danger", "warning", "info", "success"))
        ),
        mainPanel(
          bsCollapse(id = "collapseExample", open = "Panel 2",
                     bsCollapsePanel("Panel 1", "This is a panel with just text ",
                                     "and has the default style. You can change the style in ",
                                     "the sidebar.", style = "info"),
                     bsCollapsePanel("Panel 2", "This panel has a generic plot. ",
                                     "and a 'success' style.", plotOutput("genericPlot"), style = "success")
          ),

          uiOutput("tooltip_test"),
          bsTooltip("test", title = "Test", placement="right"),
          actionButton("test2", "Test2"),
          bsTooltip("test2", title = "Test2", placement="right")
        )
      )
    ),
  server = 
    function(input, output, session) {
      output$genericPlot <- renderPlot(plot(rnorm(100)))  
      observeEvent(input$p1Button, ({
        updateCollapse(session, "collapseExample", open = "Panel 1")
      }))
      observeEvent(input$styleSelect, ({
        updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect))
      }))

      output$tooltip_test <- renderUI({
        actionButton("test", "Test")
      })
    }
)

runApp(app)

What's also very strange is that if I remove the collapse panels (e.g. just have the actionButtons and tooltips in the mainPanel) then both tooltips work perfectly.

Can't get shinyBS to work at all

Hi ebailey78,

Thanks so much for a great package! The demo works great, however, I can't seem to get it to work in my app. Any input? I'm trying to: 1. use bsActionButton instead of actionButton; and 2. highlightRows, neither of which seem to work. Thinking it has to do with shiny not loading....

ui.R:

source("choices.R")
source("inputOptions.R")
library(shiny)
library(shinyBS)
## Begin ShinyUI
shinyUI(fluidPage(

## Set title of the page (includes <h1> tag)
titlePanel(""),

## Set up page with a sidebar and main panel
sidebarLayout(
    sidebarPanel(
        fluidRow(
            column(12, h5("Customize your query below:")),
            column(12, selectInput("population", label = h6("Select Population"), choices = population)),
            column(12, selectInput("year", label = h6("Select Year"), choices = year)),
            column(12, selectInput("locationType", label = h6("Select Geographic Level"), choices = geography)),
            conditionalPanel(
                condition = "input.locationType == 'Counties'",
                column(12, selectizeInput("coLocation", h6("Select County"), choices = counties, options = coOptions))
                ),
            conditionalPanel(
                condition = "input.locationType == 'Regions'",
                column(12, selectizeInput("regLocation", h6("Select Region"), choices = regions, options = regOptions))
                ),
            column(12, bsActionButton("getResults", label = "Get results!"))
            )
        ),

    mainPanel(
        textOutput("cycle"),
        dataTableOutput("results")
        )
    )

))

server.R:

library(shiny)
library(shinyBS)  
shinyServer(function(input, output, session) {
    updateButton(session, "getResults", style = "default", size = "default", disabled = FALSE)
    output$results <- renderDataTable({

    input$getResults ## Take a dependency on input$getResults button
    if(input$getResults == '0') { return() } ## Initial load with no button press, show nothing
    else {

        data <- isolate( ## Create data by concatenating different values from the input fields
            read.csv(file = paste("data/", input$year, "/", input$population, "/", input$locationType, "/",
                                  input$coLocation, ".csv", sep=""), check.names = FALSE)
            )
        highlightRows(session ,'results', column = "2", class = "info")
        print(data, type='html') # Print data to console to show on screen


    }

},
options = list( # data table options to remove certain additional/advanced features
    column.searchable = FALSE,
    searching = FALSE,
    paging = FALSE,
    ordering = FALSE
)

)

output$cycle <- renderText("The data in this website is fictitious.")

})

bsTypeAhead won't display choices unless updateTypeAhead is called

I've been trying to use bsTypeAhead in one of my Shiny Apps, but no matter what I try, bsTypeAhead won't display a choice of inputs when I type something.

I've tried to investigate the issue and found out that it doesn't work unless I call updateTypeAhead immediately after declaring the bsTypeAhead.

This doesn't work:

# ui.R
pollutants <- c('Acetone', 'Acrolein', 'Benzene', 'Benzyl Chloride')
bsTypeAhead("ta1", label = "Pollutants:", choices = pollutants, items=4)

But this does:

# ui.R
pollutants <- c('Acetone', 'Acrolein', 'Benzene', 'Benzyl Chloride')
bsTypeAhead("ta1", label = "TypeAhead:", choices = pollutants, items=4),
htmlOutput("updateTA")
# server.R
output$updateTA <- renderText({
    pollutants <- c('Acetone', 'Acrolein', 'Benzene', 'Benzyl Chloride')
    updateTypeAhead(session, inputId = "ta1", label = "TypeAhead:", choices=pollutants)
    return("")
})

You can replicate this problem by commenting out eval(parse(text=code)) in the TypeAhead section of your demo (to prevent updateTypeAhead from running).

Am I doing something wrong, or is this how bsTypeAhead is supposed to be used?

Different display format from previous version

Hi,

Great package! Thank you for providing it. I just wanted to let you know that the new version does not display correctly as opposed to previous version. Here is what I am running in updated environment:

shinyBS_0.50 shiny_0.11.1

The older session that seems to display correctly:

shinyBS_0.20 shiny_0.10.2.2

Using the same code in R, here are the screen shots. Here is the correctly formatted:

image

Here is the latest:

image

Notice how there are no borders. Also, the fields in Shiny do not appear to be CSS correctly:

image

I am holding off on updating in production because I am concerned that if I update, the shiny UI won't display correctly.

Thanks in advance for any help.

Best,
John

Programatically Trigger a Modal

Currently, it only possible by the user action of clicking a link or button. I would like a function I could use in my Shiny application to do it programatically.

Can't attach a popover to an input generated via renderUI

Maybe I'm missing something here, but I've tried addPopover and bsPopover. Both don't work for me on inputs made with renderUI:

library(shiny)
library(shinyBS)
runApp(
    list(
        ui = bootstrapPage(
            uiOutput("textInputViaUiOutput"),
            textOutput("textoutput1"),
            textInput(inputId = "textInput2", label = "Popover works"),
            textOutput("textoutput2"),
            bsPopover(id = "textInput2", title = "Test via bsPopover", "adding a popover to an input defined in ui.R works fine.")
        ),
        server = function(input, output, session) {

                output$textInputViaUiOutput <- renderUI({
                    textInput(inputId = "textInput1", label = "Popover broken");    
                })
                addPopover(session, id = "textInput1", title = "Test via addPopOver", "can't make it work with input defined in server.R");

                output$textoutput1 <- renderText(input$textInput1);
                output$textoutput2 <- renderText(input$textInput2);

            }
        )
)

Row limit in bsModal?

Hello,
I'm using a modal to display an editable rhandsontable, and I can only see the first 46 rows. Is this a limit of bsModal?
thank you for the help!

Error in shinyBS:bsModal

Hi,
Thank you for the module shinyBS. It was exactly what I was looking for.
I am trying to use bsModal feature in my application. When I click on a button(trigger), it does open a form with desired controls on it. But it appears faded (the way it looks in case of an error in the R Shiny application), and if I click anywhere on the form it gets closed. Any help regarding this would be much appreciated, as this is one of the key features of my application.

Here is my code snippet:

bsModal("modeldataform", "Update Model Data", "buttonupdatemodel", size = "large",
textInput("mmodel", label = "Model", value = "")
textInput("meventset", label = "Event Set", value = ""),
textInput("mportfolio", label = "Portfolio", value = ""),
textInput("muserid", label = "Username", value = ""),
actionButton("buttonsubmitum", "Submit", class="btn btn-primary", align = "right")
)#End of bsModal

Regards,
Manali

bsModal and dateinput

Hi there,

I am trying to add a dateinput to a bsModal, however the calendar widget is in the background/ behind the Modal and can not be used. Any ideas?

image

library(shiny)
library(shinyBS)

shinyApp(
  ui =fluidPage(
    mainPanel(
      dataTableOutput("x1"),
      bsModal("modalExample", "Data Table", "rowtogg", size = "large",
              dateInput("dates", "Enter date"))
    )
  ),



  server = function(input, output, session) {
    output$x1 <- renderDataTable({
      DT::datatable( data.frame(x = 1:4), selection = "single" )
    }, server = FALSE)

    observeEvent({
      input[[paste( "x1", "rows_selected", sep="_" )]]
    },{

      toggleModal(session, "modalExample", "open")
    })
  }
)

bsModal close event?

Hi,

Is there any way to include some code in a close event of bsModal?

I wanted to do some cleanup job, like reset button status after user close the Modal.

bsModal and navbarpage

Do you think it's possible to combine the use of bsModal and a navbarpage so that the bsButton only appears on a defined tab; if i try this in ui.R, i receive this message from server :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Thanks
KR
Alain

ui.r

shinyUI(bootstrapPage(

shinyUI(navbarPage("testtest",

tabPanel("Test1"
,h1("Hello, welcome to shiny")
),

tabPanel("Test2"
,h1("Hello, welcome to shiny 2")
,bsButton("moTrig", "open Modal", style = "primary"),

bsModal("moMod", "Welcome message", trigger = "moTrig",
tags$head(
tags$style(HTML("
.modal{
width: 90%;
left: 5%;
margin-left:auto;
margin-right:auto;
height: auto;
}
.modal-body {
color: green;
}
"))
),

    h1("Hello, welcome to shiny3"),         )

)

)
))

updateButton(..., disabled = FALSE) in a modal

Hello, I have tried to use a bsButton for the first time initializing it as disabled and updating it when a condition is met. However, it fails to get enabled. Should work for buttons inside a bsModal?
thank you!

updateSlider input does not work correctly in modals

I already asked this at shiny, but as it turned out this was an issue of the modal, so I thought I'd ask here:

To replicate the error:

  1. open modal via button
  2. Look at the text Output and the slider/selectize values in the UI

image

While both the slider and selectize are updated to 5 in the UI, the input value for the slider is not updated. This only happens at the beginning. If the user changes the slider manually or uses the numericInput the input value is updated accordingly.

This error does not occur if you leave out the modal.

library(shiny)
library(shinyBS)

shinyApp(
  ui = fluidPage(
    mainPanel(
      actionButton("modal", "open modal"),
      shinyBS::bsModal(id = "row", trigger = "matrigg",
                       h2("Look at the text out put below before you change anything"),
                       textOutput("print"),
                       sliderInput("slider1", "my_slider", min = 1, max = 5, value = 1),
                       selectizeInput("selectize", "selectize", choices = 1:5, selected = 1),
                       numericInput("numinput", "Numbers", value = 5)
      )
    )
  ),
  server = function(input, output, session) {
    observeEvent({
      input$modal
    },{
       # Error only happens when a modal is used
      shinyBS::toggleModal(session, "row")
    })

    observeEvent({
      input$numinput
    },{
      updateSliderInput(session, "slider1", max = input$numinput, value = input$numinput)
      updateSelectizeInput(session, "selectize", choices = 1:input$numinput, selected = input$numinput)
    })

    output$print <- renderText({
      paste0("Slider value: ", input$slider1,"\nSelectize value :", input$selectize)
    })
  }
)

Modals triggered by non-user interaction

Hi,

Great package - really like the range of buttons and modal feature.

Is it possible to have a modal trigger off non-user interaction?

For example, I would like to have a modal trigger after a reactivepoll has returned or
an invalidateLater timer has expired.

I attempted to use the updateButton callback which triggers the modal but with no success. I believe the code `$('#myModal').modal('show');`` will achieve what I want but I'm not sure how to implement this within shiny.

Cheers

tooltips for table cells

I have a shiny application that presents a user with a list of tables to view. The default table is displayed using renderDataTable(). Meanwhile, I present the column names and their definitions in a separate (updatable) table in the side bar. I am looking for a way to present additional descriptors (units, factor level definitions) when the user hovers/clicks elements in the sidebar table. Does shinyBS support a mechanism for this? I'm guessing popovers will not work, per the disclaimer: "currently cannot contain shiny inputs or outputs".

multiple bsTooltip showing the same content

Hi,
I'm having an issue in adding multiple Tooltips in my shiny app. Even if I link them to different inputId in my ui.R, they all show the same content (always the one of the last tooltip).
Here is a minimal reproducible example:

library (shiny)
library (shinyBS)

runApp(
list(
ui = fluidPage(
selectInput(inputId = "1st", label = "1st choice",
choices = c("a", "b", "c")),
br(),
selectInput(inputId = "2nd", label = "2nd choice",
choices = c("d", "e", "f")),

  bsTooltip(id = "1st", "do something", "right", trigger="hover"),
  bsTooltip(id = "2nd", "do something else", "right", trigger="hover")
),

server = function(input, output) {
}

)
)

Any advice will be highly appreciated.
Thanks in advance.
Best,
Massimo

customize bsModal footer

Make it possible to customize the elements present in the footer of the modal dialog created with bsModal.

Popover word limit?

Dear Eric,

First off, thanks for the awesome set of Shiny extensions. It was delightful to find a package that not only had high-quality features but that also seemed to be written Shiny-style. Your work is very appreciated. =)

My question: What is the exact word limit for popover/tooltip content? I'm guessing there is one because I observed that some of my longer popovers simply won't activate when clicked.

Below are a pair of reproducible examples. The only (I think) difference between them is the length of the string passed to "content" in bsPopover.

Note: I've set the example to mirror some of the global features of my actual project (e.g., column width and page type) just in case those are relevant.

Thank again for your work and for any more time you have to share!

Warm regards,
Brian

popover works

library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("x_axis_choice", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("x_axis_choice",
                                 title = "Variable Definitions.",
                                 content = "<p> So many puppies! How do they make me feel? <br> I heart them. SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY much. </p>",
                                 trigger = "click",
                                 placement = "bottom")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

popover doesn't work

library(shiny)
shinyApp(
    ui = navbarPage(
        "The Case Outcome Simulator",

        # using COS to explore trends per predictor ("Explore Mode")
        tabPanel("Explore Mode", fluidPage(
            # define user tools in the first column
            # width = 3 of 12 (Shiny divides the horizontal space up into 12 sections)
            column(3, 
                   wellPanel(               
                       radioButtons("x_axis_choice", label = h4("Select X-Axis"), 
                                    choices = c("one", "two", "three")),

                       bsPopover("x_axis_choice",
                                 title = "Variable Definitions.",
                                 content = "<p> So many puppies! How do they make me feel? <br> I heart them. SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY SO VERY VERY VERY VERY VERY much. <br> I REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY REALLY can't stress this enough.</p>",
                                 trigger = "click",
                                 placement = "bottom")
                   )
            ),
            column(9,
                   textOutput("return_stuff")
            )
        ))
    ), 
    server = function(input, output, session) {
        output$return_stuff <- renderText({input$"x_axis_choice"})
    }
)

hr in bsModal Body

Hello,

thank you for your work, i have a question: i want to organize the modal body into div with classes =row-fluid, it works fine, but i can not add hr() between my lines, i tried several methods, but nothing, when i launch element inspection in the browser i can see it?
here is an example of application code:

rm(list=ls())

library(shiny)
library(shinyBS)
library(shinyjs)

modal = shinyApp(ui =bootstrapPage(
  useShinyjs(),
  div(class="row-fluid",
      column(10, offset = 2,
             h4("test ui output"),
             actionButton(inputId = "click", label = "test Modal output"),
             bsModal(id = "modal", title = "Modal render", trigger = "click", size = "large",
                     div(class="row-fluid",
                         column(width=6,
                                h6("first Oper" ,style="color:blue; font-weight: bold;")
                         ),
                         column(width=6,
                                h6("Second Oper", style="color:blue;font-weight: bold;")
                         )
                     ),
                     hr(style="border:5px;"),                               
                     div(class="row-fluid",
                         column(width=6,
                                textOutput(outputId = "secondOper")
                         ),
                         column(width=6,
                                textOutput(outputId = "firstOper")
                         )
                     ),
                     tags$hr(),
                     div(class="row-fluid",
                         column(width=6,
                                h6("second Step" ,style="color:blue;font-weight: bold;")
                         ),
                         column(width=6,
                                h6("first Step" ,style="color:blue;font-weight: bold;")
                         )
                     ),
                     div(class="row-fluid",
                         column(width=6,
                                textOutput(outputId = "secondStep")
                         ),
                         column(width=6,
                                textOutput(outputId = "firstStep")
                         )
                     ),
                     hr(style="border-top:5px;"),
                     div(class="row-fluid",
                         dataTableOutput("cars")
                     ),
                     actionButton("buttonsubmitum", "Submit", class="btn btn-primary")

             )

      )                
  )            
),
server= function(input, output, session){
  output$cars = renderDataTable(cars, options = list(pageLength=10))
} )
runApp(modal, launch.browser = TRUE)

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.