Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions R/mod_chartsNav.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ chartsNavUI <- function(id, chart) {
#' @export
#'

chartsNav<-function(input, output, session, chart, data, mapping){
chartsNav<-function(input, output, session, chart, data, mapping, module_outputs) {
ns <- session$ns

chartStatus <- reactive({
Expand All @@ -42,6 +42,7 @@ chartsNav<-function(input, output, session, chart, data, mapping){
}else{
status<-NULL
}

return(status)
})

Expand All @@ -54,12 +55,15 @@ chartsNav<-function(input, output, session, chart, data, mapping){
)
})

callModule(
module_output <- callModule(
module=chartsTab,
id='chart',
chart=chart,
data=data,
mapping=mapping,
status=chartStatus
status=chartStatus,
module_outputs = module_outputs
)

module_output
}
31 changes: 25 additions & 6 deletions R/mod_chartsTab.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,22 @@ chartsTabUI <- function(id, chart){
#'
#' @export

chartsTab <- function(input, output, session, chart, data, mapping, status){
chartsTab <- function(input, output, session,
chart,
data,
mapping,
status,
module_outputs
) {
ns <- session$ns

# Draw the header
output$`chart-header` <- renderUI({makeChartSummary(chart, status=status())})
output$`chart-header` <- renderUI({
makeChartSummary(
chart,
status=status()
)
})

# Initialize chart-specific parameters
params <- reactive({
Expand All @@ -44,16 +55,22 @@ chartsTab <- function(input, output, session, chart, data, mapping, status){
})

# Draw the chart
if(chart$type=="module"){
callModule(chart$functions$main, "chart-wrap", params)
}else{
output[["chart-wrap"]] <- chart$functions$server(
if(chart$type=="module") {
module_output <- callModule(
chart$functions$main,
"chart-wrap",
params,
module_outputs
)
} else {
module_output <- output[["chart-wrap"]] <- chart$functions$server(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anything actually being returned here for non-shiny charts? I guess in theory the main function could return something, but is this just NULL for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, nothing now... I can imagine returning a filtered/transformed dataset or a population subset.

do.call(
chart$functions$main,
params()
)
)
}

# Download R script
insertUI(
paste0(".",ns("header"), " .chart-header"),
Expand Down Expand Up @@ -107,4 +124,6 @@ chartsTab <- function(input, output, session, chart, data, mapping, status){
}
)
}

return(module_output)
}
25 changes: 15 additions & 10 deletions R/mod_safetyGraphicsServer.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,22 @@ safetyGraphicsServer <- function(input, output, session,
shinyjs::hide(selector = paste0(".navbar li a[data-value='profile']"))
shinyjs::hide(selector = paste0(".navbar #pt-header"))
}

#--- Charts tab ---#
charts %>% purrr::walk(
~callModule(
module=chartsNav,
id=.x$name,
chart=.x,
data=filtered_data,
mapping=current_mapping
)
)
module_outputs <- reactiveValues()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reactiveValues is actually what's working. It allows passing around a single, updateable object of reactive modules.

charts %>%
purrr::walk(function(chart) {
module_output <- callModule(
module=chartsNav,
id=chart$name,
chart=chart,
data=filtered_data,
mapping=current_mapping,
module_outputs=module_outputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be module_outputs1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the module_outputs of returned map output.

)

module_outputs[[ chart$name ]] <- module_output
})

#--- Settings tab ---#
callModule(
Expand Down