Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ui <- fluidPage(
- radioButtons("plotType", "Plot Type:", choices = c("ggplotly", "plotly")),
- plotlyOutput("plot"
- ),
- verbatimTextOutput("click"),
- verbatimTextOutput("brush")
- )
- server <- function(input, output, session) {
- output$plot <- renderPlotly({
- # use the key aesthetic/argument to help uniquely identify selected observations
- key <- row.names(mtcars)
- if (identical(input$plotType, "ggplotly")) {
- p <- ggplot(data, aes(x = c(1:nrow(data)) , y = y, colour = factor(WF_ID), key = LOT_CODE)) +
- geom_line(color="black") + geom_point()
- ggplotly(p) %>% layout(dragmode = "select")
- } else {
- plot_ly(data, x = ~c(1:nrow(data)), y = ~y, key = ~data$LOT_CODE, mode = 'lines+markers') %>%
- layout(dragmode = "select")
- }
- })
- output$click <- renderPrint({
- d <- event_data("plotly_click")
- if (is.null(d)) "Click events appear here (double-click to clear)" else d
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement