New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
m_grid does not update in Shiny app with selectInput #42
Comments
Thanks for reporting that. Although I have not done enough research, but I think this should be a bug, thank you very much for the sample, I will go to solve the problem as soon as possible. |
fix: grid layout dose not update in Shiny app (#42)
@alanzos I think I have fixed the bug, please use the latest version and have a try. see #44. # install.packages("devtools")
devtools::install_github("swsoyee/r3dmol") About the waring in the console
You could use library(shiny)
library(r3dmol)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("selected_id", "Choose a PDB ID:", choices=c("3G5X","7A2A","5IJ5")),
),
mainPanel(
## Choose multi or individual, but not both at the same time
r3dmolOutput(outputId = "structure_multi"),
r3dmolOutput(outputId = "structure_individual"),
)
)
)
server <- function(input, output, session) {
output$structure_individual <- renderR3dmol({
r3dmol() %>%
m_add_model(data = m_fetch_pdb(input$selected_id)) %>%
m_zoom_to() %>%
m_set_style(style = m_style_cartoon(color = "spectrum"))
})
output$structure_multi <- renderR3dmol({
m1 <- r3dmol() %>%
m_add_model(data = m_fetch_pdb(input$selected_id)) %>%
m_zoom_to()
m2 <- m1 %>%
m_set_style(style = m_style_cartoon(color = "spectrum"))
m3 <- m1 %>%
m_set_style(style = m_style_stick())
m4 <- m1 %>%
m_set_style(style = m_style_sphere())
grid <- m_grid(
viewer = list(m1, m2, m3, m4),
control_all = TRUE,
viewer_config = m_viewer_spec(
backgroundColor = "black"
)
)
grid$elementId <- NULL # suppress the `Shiny doesn't use them` warning
grid
})
}
shinyApp(ui, server) If you still have any problem please let me know. Thank you! |
Wow that was fast, it works perfectly. Many thanks 👍 |
Hi,
Thanks for making r3dmol. It's a really nice package and easy to use.
I'm using m_grid in a Shiny app with selectInput. But the output graphic is not updated when changing the input in the selection menu on the left.
The individual graphics are updated, but not the multi graphic.
And I get this error on the console:
Warning in renderWidget(instance) :
Ignoring explicitly provided widget ID "c6ce055b66d1daf14e50"; Shiny doesn't use them
Any idea why? and a possible solution?
Thanks in advance :)
Example below:
The text was updated successfully, but these errors were encountered: