Hide or show an existing NGLVieweR selection in Shinymode.

updateVisibility(NGLVieweR_proxy, name, value = FALSE)

Arguments

NGLVieweR_proxy

A NGLVieweR object.

name

Name of selection to alter the color.

value

Hide FALSE or show TRUE selection. For a full description see "setVisibility" in the official NGL.js manual.

Value

API call containing NGLVieweR id and list of message parameters.

See also

NGLVieweR_example() See example "updateVisibility".

Other updates: updateColor(), updateRepresentation(), updateStage()

Examples

if (FALSE) { # \dontrun{
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)
}