Description Usage Arguments Value See Also Examples
Update an existing NGLVieweR representation in Shinymode.
1 | updateRepresentation(NGLVieweR_proxy, name, param = list())
|
NGLVieweR_proxy |
A NGLVieweR object. |
name |
Name of representation to alter the color. |
param |
Options for the different types of representations. Most common options are |
API call containing NGLVieweR
id
and list of message parameters.
addSelection()
Add a new selection to a NGLVieweR object.
addRepresentation()
NGLVieweR_example()
See example "updateRepresentation".
Other updates:
updateColor()
,
updateStage()
,
updateVisibility()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ## Not run:
NGLVieweR_proxy("structure") %>%
updateRepresentation("cartoon",
param = list(
name = "cartoon",
color = isolate(input$color),
opacity = isolate(input$opacity)
)
)
## End(Not run)
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.