Update color of an existing NGLVieweR selection in Shinymode.
updateColor(NGLVieweR_proxy, name, color)
A NGLVieweR object.
Name of selection to alter the color.
Can be a colorValue (color name or HEX code) or colorScheme (e.g. "element", "resname", "random" or "residueindex"). For a full list of options, see the "Colormaker" section in the official NGL.js manual.
API call containing NGLVieweR
id
and list of message
parameters.
NGLVieweR_example()
See example "updateColor".
Other updates:
updateRepresentation()
,
updateStage()
,
updateVisibility()
if (FALSE) { # \dontrun{
NGLVieweR_proxy("structure") %>%
updateColor("cartoon", "red")
} # }
if (interactive()) {
library(shiny)
library(colourpicker)
ui <- fluidPage(
titlePanel("Viewer with API inputs"),
sidebarLayout(
sidebarPanel(
colourInput("color", "red", "red"),
actionButton("update", "Update"),
),
mainPanel(
NGLVieweROutput("structure")
)
)
)
server <- function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", color = "residueindex")
)
})
observeEvent(input$update, {
NGLVieweR_proxy("structure") %>%
updateColor("cartoon", isolate(input$color))
})
}
shinyApp(ui, server)
}