RinteRface / shinyMobile

shiny API for Framework7 (IOS/android)
https://shinymobile.rinterface.com
407 stars 74 forks source link

renderPlot / PlotOutput not showing Plots #232

Closed usingdatascience closed 1 year ago

usingdatascience commented 2 years ago

I have literally cut and pasted some code from the examples, in order to help my understanding of ShinyMobile etc, and the PLOTS are NOT being displayed when i run my shiny app. I get a blank screen .... my code is below (as i said, cut and pasted from one of the examples) ... any help as to why the plots are not showing would be much appreciated...

library(dplyr) library(ggplot2)

library(shiny) library(shinyMobile) shiny::shinyApp( ui = f7Page( title = "My app", f7SingleLayout( navbar = f7Navbar( title = "Standalone tabs", hairline = FALSE, shadow = TRUE ), f7Tabs( id = "tabs", style = "strong", animated = FALSE, swipeable = TRUE, f7Tab( tabName = "Tab 1", icon = f7Icon("envelope"), active = TRUE, f7Shadow( intensity = 10, hover = TRUE, f7Card(

title = "Card header",

                    #    f7Stepper(
                    #        "obs1",
                    #        "Number of observations",
                    #        min = 0,
                    #        max = 1000,
                    #        value = 500,
                    #        step = 100
                    #    ),
                        print("starting plot"),
                        plotOutput("distPlot")
                    )
                )
            ),
            f7Tab(
                tabName = "Tab 2",
                icon = f7Icon("today"),
                active = FALSE,
                f7Shadow(
                    intensity = 10,
                    hover = TRUE,
                    f7Card(
                        title = "Card header",
                        f7Select(
                            inputId = "obs2",
                            label = "Distribution type:",
                            choices = c(
                                "Normal" = "norm",
                                "Uniform" = "unif",
                                "Log-normal" = "lnorm",
                                "Exponential" = "exp"
                            )
                        ),
                        uiOutput("distPlot2")
                    )
                )
            ),
            f7Tab(
                tabName = "Tab 3",
                icon = f7Icon("cloud_upload"),
                active = FALSE,
                f7Shadow(
                    intensity = 10,
                    hover = TRUE,
                    f7Card(
                        title = "Card header",
                        f7SmartSelect(
                            inputId = "variable",
                            label = "Variables to show:",
                            c("Cylinders" = "cyl",
                              "Transmission" = "am",
                              "Gears" = "gear"),
                            multiple = TRUE,
                            selected = "cyl"
                        ),
                        tableOutput("data")
                    )
                )
            )
        )
    )
),
server = function(input, output) {
    output$distPlot <- renderPlot({
        dist <- rnorm(input$obs1)
        hist(dist)
    })

    output$distPlot2 <- renderPlot({
        dist <- switch(
            input$obs2,
            norm = rnorm,
            unif = runif,
            lnorm = rlnorm,
            exp = rexp,
            rnorm
        )

        hist(dist(500))
    })

    output$data <- renderTable({
        mtcars[, c("mpg", input$variable), drop = FALSE]
    }, rownames = TRUE)
}

)

usingdatascience commented 2 years ago

Here is a screenshot of my shiny app when running, distPlot is for some reason not being displayed on the first tab ... image

DivadNojnarg commented 2 years ago

Have a try with the shinyMobile rc-1.0.0 branch which is currently in preparation. It is probably coming from a recent breaking change in shiny 1.7.2.

DivadNojnarg commented 2 years ago

See #228.