ijlyttle / bsplus

Shiny and R Markdown addons to Bootstrap 3
http://ijlyttle.github.io/bsplus/
Other
146 stars 23 forks source link

Carousel for dynamic plots #44

Closed ktrev closed 4 years ago

ktrev commented 7 years ago

We got a carousel, but only the first plot is being displayed.The other slides are blank. Wondering if any one can help to solve this. https://revathy.shinyapps.io/test/ The reproducible code with error is

## app.R ##
require("shiny")
require("shinydashboard")
require("bsplus")
options(encoding = 'UTF-8')

## ui ##
header <- dashboardHeader(
    title = "mooKIT Analytics"
    #dropdownMenuOutput("messageMenu")
)

sidebar <- dashboardSidebar(
    sidebarMenu(id="menu",

                menuItem("Interaction", tabName = "engagement", icon = icon("bullseye"), selected = T)
    )
)

body <- dashboardBody(

    tabItems(

        tabItem(tabName = "engagement",
                fluidRow(
                    tabBox(id="", width=12,

                           tabPanel(icon = icon('link'), "Network",
                                    uiOutput("ex1")
                           )
                    )
                )
        )
    )
)

ui <- dashboardPage(header, sidebar, body)

## server ##
server <- function(input, output, session) {

    set.seed(122)
    histdata <- rnorm(500)
    observe({
        output$ex1 <- renderUI({    
                plot_output_list <- lapply(1:4, function(i) {
                      plotname <- paste("forumSNGweek", i, sep="")
                      box(plotOutput(plotname), height = 280, width = 250)
                })
                #box(sigmaOutput("forumSNG2",width = "98%",height = "630px"), width = 14, height = "650px")
                plotters <- bs_carousel(id = "carousel", use_indicators = TRUE)
                Reduce(bs_append, plot_output_list, init=plotters)
        })

        for(i in 1:4) {
            plotname <- paste("forumSNGweek", i, sep="")
            output[[plotname]] <- renderPlot({
                data <- histdata[seq_len(50)]
                hist(data)
              })
        }
    })
}
## Run App ##
shinyApp(ui, server)
ijlyttle commented 7 years ago

Sorry I have not had a chance to look at this yet - my day-job is preventing me from doing much else at the moment.

tsolloway commented 5 years ago

https://github.com/RinteRface/shinydashboardPlus/issues/36

... would be a new starting place. I'm having some problems placing a dynamic number of uiOutput's in a carousel. Let me know if you've solved your problem. Why are you opting for bs_carousel rather than the plus carousel? Or was that function not available in 2017?

ijlyttle commented 5 years ago

It looks like the difference between the two is the the presence of a JS snippet that helps the carousel work in a Shiny environment. Perhaps this snippet would help in this case.

tsolloway commented 5 years ago

Agreed. One note is that the snippet only works on the dev version, so there's a shift in code somewhere that us JS/html-novices don't appreciate.

Awesome package! Thank you for it!