Update an existing NGLVieweR representation in Shinymode.
updateRepresentation(NGLVieweR_proxy, name, param = list())
A NGLVieweR object.
Name of representation to alter the color.
Options for the different types of representations. Most common options are name
, opacity
, colorScheme
, colorValue
and visibility
.
For a full list of options, see the general "RepresentationParameters" method and type specific Label-, Structure- and Surface- RepresentationParameters in the official NGL.js manual.
API call containing NGLVieweR
id
and list of message parameters.
addSelection()
Add a new selection to a NGLVieweR object.
NGLVieweR_example()
See example "updateRepresentation".
Other updates:
updateColor()
,
updateStage()
,
updateVisibility()
if (FALSE) {
NGLVieweR_proxy("structure") %>%
updateRepresentation("cartoon",
param = list(
name = "cartoon",
color = isolate(input$color),
opacity = isolate(input$opacity)
)
)
}
if (interactive()) {
library(shiny)
ui = fluidPage(
titlePanel("Viewer with API inputs"),
sidebarLayout(
sidebarPanel(
selectInput("color", "Color", c("red", "white", "blue")),
sliderInput("opacity", "Opacity", 0, 1, 1),
actionButton("update", "Update"),
),
mainPanel(
NGLVieweROutput("structure")
)
)
)
server = function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", color="red"))
})
observeEvent(input$update, {
NGLVieweR_proxy("structure") %>%
updateRepresentation("cartoon",
param = list(
color = isolate(input$color),
opacity = isolate(input$opacity)
)
)
})
}
shinyApp(ui, server)
}