Skip to content

Commit

Permalink
hide table when not brushed
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 21, 2024
1 parent 4321350 commit 4137aa1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 6 additions & 3 deletions R/tm_p_swimlane2.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ ui_p_swimlane2 <- function(id) {
ns <- NS(id)
shiny::tagList(
plotly::plotlyOutput(ns("plot")),
ui_page_data_table(ns("brush_tables"))
shinyjs::hidden(div(
id = ns("brushing_wrapper"),
ui_page_data_table(ns("brush_tables"))
))
)
}

Expand Down Expand Up @@ -58,9 +61,9 @@ srv_p_swimlane2 <- function(id,

brush_filtered_data <- reactive({
if (is.null(brush_filter_call())) {
shinyjs::hide("brush_tables")
shinyjs::hide("brushing_wrapper")
} else {
shinyjs::hide("show_tables")
shinyjs::show("brushing_wrapper")
eval_code(plotly_q(), as.expression(brush_filter_call()))
}
})
Expand Down
17 changes: 9 additions & 8 deletions inst/poc_adam_plotly.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pkgload::load_all("teal")
pkgload::load_all("teal.widgets")
library(plotly)
pkgload::load_all("teal.modules.general")

# Example data
Expand All @@ -10,7 +9,8 @@ data <- within(teal_data(), {
EOTSTT2 = case_when(
!is.na(DCSREAS) ~ DCSREAS,
TRUE ~ EOTSTT
)
),
TRTLEN = as.integer(TRTEDTM - TRTSDTM)
)

ADAE <- teal.data::rADAE
Expand All @@ -21,21 +21,22 @@ join_keys(data) <- default_cdisc_join_keys


plotly_specs <- list(
list("plotly::add_bars", x = ~EOSDY, y = ~USUBJID, data = quote(ADSL)),
list("plotly::add_markers", x = ~EOSDY, y = ~USUBJID, color = ~EOTSTT2, data = quote(ADSL)),
list("plotly::add_markers", x = ~ADY, y = ~USUBJID, data = quote(ADRS))
list("plotly::add_bars", x = ~TRTLEN, y = ~USUBJID, color = ~ARM, data = quote(ADSL)),
list("plotly::add_markers", x = ~ADY, y = ~USUBJID, color = ~AVALC, symbol = ~AVALC, data = quote(ADRS))
)


app <- init(
data = data,
modules = modules(
tm_data_table(),
tm_p_swimlane2(
tm_p_plotly(
label = "Swimlane",
plotly_specs = plotly_specs,
title = "Swimlane Efficacy Plot"
)
),
filter = teal_slices(
teal_slice("ADSL", "AGE", selected = c(20, 25))
)
)

Expand Down

0 comments on commit 4137aa1

Please sign in to comment.