From 4137aa1f687e8c98877fd2ecc8b6f9f2da8bc9bd Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Thu, 21 Nov 2024 16:33:08 +0100 Subject: [PATCH] hide table when not brushed --- R/tm_p_swimlane2.r | 9 ++++++--- inst/poc_adam_plotly.r | 17 +++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/R/tm_p_swimlane2.r b/R/tm_p_swimlane2.r index 1b5f08944..bb1580697 100644 --- a/R/tm_p_swimlane2.r +++ b/R/tm_p_swimlane2.r @@ -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")) + )) ) } @@ -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())) } }) diff --git a/inst/poc_adam_plotly.r b/inst/poc_adam_plotly.r index 6b5ef312d..673595d01 100644 --- a/inst/poc_adam_plotly.r +++ b/inst/poc_adam_plotly.r @@ -1,5 +1,4 @@ -pkgload::load_all("teal") -pkgload::load_all("teal.widgets") +library(plotly) pkgload::load_all("teal.modules.general") # Example data @@ -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 @@ -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)) ) )