updateStage: Update Stage

Description Usage Arguments Value See Also Examples

View source: R/api.R

Description

Update an existing NGLVieweR stage in Shinymode.

Usage

1

Arguments

NGLVieweR_proxy

A NGLVieweR object.

param

Of type list. Most common options are backgroundColor, rotateSpeed, zoomSpeed, hoverTimeout and lightIntensity. For a full list of options, see the "StageParameters" method in the official NGL.js manual.

Value

API call containing NGLVieweR id and list of message parameters.

See Also

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

Examples

 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
## Not run: 
NGLVieweR("7CID") %>%
 addRepresentation("cartoon", 
                   param = list(name = "cartoon", color="red")) %>%
 stageParameters(backgroundColor = "black")

## End(Not run)

if (interactive()) {
library(shiny)

ui = fluidPage(
  titlePanel("Viewer with API inputs"),
  sidebarLayout(
    sidebarPanel(
      selectInput("background", "Background", c("black", "white", "blue")),
      actionButton("update", "Update"),
    ),
    mainPanel(
      NGLVieweROutput("structure")
    )
  )
)
server <- function(input, output) {
  output$structure <- renderNGLVieweR({
    NGLVieweR("7CID") %>%
      addRepresentation("cartoon",
        param = list(name = "cartoon", color = "red")
      ) %>%
      stageParameters(backgroundColor = "black")
  })
  observeEvent(input$update, {
    NGLVieweR_proxy("structure") %>%
      updateStage(
      param = list("backgroundColor" = isolate(input$background)))
  })
}
shinyApp(ui, server)
}

NGLVieweR documentation built on June 1, 2021, 9:08 a.m.