File tree Expand file tree Collapse file tree 2 files changed +86
-0
lines changed Expand file tree Collapse file tree 2 files changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ tm_p_swimlane2 <- function (label = " Swimlane Plot Module" , plotly_specs , title ) {
2+ module(
3+ label = label ,
4+ ui = ui_p_swimlane2 ,
5+ server = srv_p_swimlane2 ,
6+ datanames = " all" ,
7+ server_args = list (
8+ plotly_specs = plotly_specs ,
9+ title = title
10+ )
11+ )
12+ }
13+
14+
15+ ui_p_swimlane2 <- function (id ) {
16+ ns <- NS(id )
17+ shiny :: tagList(
18+ plotly :: plotlyOutput(ns(" plot" )),
19+ verbatimTextOutput(ns(" selecting" )),
20+ shinyjs :: hidden(tableOutput(ns(" table" )))
21+ )
22+ }
23+
24+ srv_p_swimlane2 <- function (id ,
25+ data ,
26+ plotly_specs ,
27+ title = " Swimlane plot" ,
28+ filter_panel_api ) {
29+ moduleServer(id , function (input , output , session ) {
30+ plotly_q <- reactive({
31+ code <- substitute(
32+ p <- plotly_specs | > plotly :: event_register(" plotly_selecting" ),
33+ list (plotly_specs = plotly_specs )
34+ )
35+ eval_code(data(), code = code )
36+ })
37+
38+ output $ plot <- plotly :: renderPlotly(plotly_q()$ p )
39+
40+ output $ selecting <- renderPrint({
41+ d <- plotly :: event_data(" plotly_selecting" )
42+ if (is.null(d )) " Brush points appear here (double-click to clear)" else d
43+ })
44+ })
45+ }
Original file line number Diff line number Diff line change 1+ pkgload :: load_all(" teal" )
2+ pkgload :: load_all(" teal.widgets" )
3+ pkgload :: load_all(" teal.modules.general" )
4+
5+ # Example data
6+ data <- within(teal_data(), {
7+ library(dplyr )
8+ library(tidyr )
9+ ADSL <- teal.data :: rADSL | > mutate(
10+ EOTSTT2 = case_when(
11+ ! is.na(DCSREAS ) ~ DCSREAS ,
12+ TRUE ~ EOTSTT
13+ )
14+ )
15+
16+ ADAE <- teal.data :: rADAE
17+ ADRS <- teal.data :: rADRS
18+ })
19+
20+ join_keys(data ) <- default_cdisc_join_keys
21+
22+ plotly_specs <- quote(
23+ plotly :: plot_ly() | >
24+ plotly :: add_bars(x = ~ EOSDY , y = ~ USUBJID , data = ADSL ) | >
25+ plotly :: add_markers(x = ~ EOSDY , y = ~ USUBJID , data = ADSL ) | >
26+ plotly :: add_markers(x = ~ ADY , y = ~ USUBJID , data = ADRS )
27+ )
28+
29+ app <- init(
30+ data = data ,
31+ modules = modules(
32+ tm_data_table(),
33+ tm_p_swimlane2(
34+ label = " Swimlane" ,
35+ plotly_specs = plotly_specs ,
36+ title = " Swimlane Efficacy Plot"
37+ )
38+ )
39+ )
40+
41+ shinyApp(app $ ui , app $ server )
You can’t perform that action at this time.
0 commit comments