Hide or show an existing NGLVieweR selection in Shinymode.
updateVisibility(NGLVieweR_proxy, name, value = FALSE)
A NGLVieweR object.
Name of selection to alter the color.
Hide FALSE
or show TRUE
selection.
For a full description see "setVisibility" in the official NGL.js manual.
API call containing NGLVieweR
id
and list of message parameters.
NGLVieweR_example()
See example "updateVisibility".
Other updates:
updateColor()
,
updateRepresentation()
,
updateStage()
if (FALSE) {
NGLVieweR_proxy("structure") %>%
updateVisibility("cartoon", value = TRUE)
}
if (interactive()) {
library(shiny)
ui = fluidPage(
titlePanel("Viewer with API inputs"),
sidebarLayout(
sidebarPanel(
actionButton("show", "Show"),
actionButton("hide", "Hide"),
),
mainPanel(
NGLVieweROutput("structure")
)
)
)
server = function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", color="residueindex"))
})
observeEvent(input$show, {
NGLVieweR_proxy("structure") %>%
updateVisibility("cartoon", value = TRUE)
})
observeEvent(input$hide, {
NGLVieweR_proxy("structure") %>%
updateVisibility("cartoon", value = FALSE)
})
}
shinyApp(ui, server)
}