quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
141 stars 7 forks source link

Support for shinylive in rmarkdown chunks too? #22

Open al-obrien opened 10 months ago

al-obrien commented 10 months ago

Perhaps I have simply just missed the information online, but now that shinylive-r works for quarto chunks, are there plans to support this feature in Rmarkdown chunks as well? Happy to transfer this post to the relevant project if this is not the appropriate spot. This would be a very interesting addition for those using {blogdown} or similar Rmarkdown flavored packages. Happy to transfer this post to the relevant project if this is not the appropriate spot.

al-obrien commented 10 months ago

To test this, I have attempted to copy the same code for the Quarto example to an Rmarkdown document within a Quarto project. The .qmd version renders fine but, although the Rmarkdown page renders, I am not sure if it is intended as it appears to stay on the loading screen for a long time (see screenshot). This seemed to only resolve if I had the window popped out of the RStudio GUI and into a browser.

---
title: "shinylive-proj"
filters:
  - shinylive
---

## Rmarkdown shinylive-r Test

Following instructions similar to Quarto 

```{shinylive-r}
#| standalone: true

library(shiny)

# Define UI for displaying current time ----
ui <- fluidPage(

  h2(textOutput("currentTime"))

)

# Define server logic to show current time, update every second ----
server <- function(input, output, session) {

  output$currentTime <- renderText({
    invalidateLater(1000, session)
    paste("The current time is", Sys.time())
  })

}

# Create Shiny app ----
shinyApp(ui, server)


## In GUI
![image](https://github.com/quarto-ext/shinylive/assets/37438544/b516db31-e74d-4755-8365-590423cbab3c)

## In Browser
![image](https://github.com/quarto-ext/shinylive/assets/37438544/a5a21d34-a03e-452d-b3b5-9bc35eaab1ba)
willgryan commented 8 months ago

I can report a similarly long loading time for shinylive-r even when viewing in a browser. Interestingly, I notice XQuartz running when it finally does load.