Skip to content

Commit

Permalink
feat: we can have cards with different plotlibs
Browse files Browse the repository at this point in the history
  • Loading branch information
ESCRI11 committed Mar 21, 2023
1 parent bc12bc2 commit 1e1d4d4
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions components/base/R/PlotModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@ PlotModuleUI <- function(id,
}

if (is.null(plotlib2)) plotlib2 <- plotlib
if (is.null(outputFunc)) outputFunc <- getOutputFunc(plotlib)
if (is.null(outputFunc2)) outputFunc2 <- getOutputFunc(plotlib2)
if (cards) {
if(length(plotlib) != length(card_names)){
plotlib <- rep(plotlib[1], length(card_names))
}
if (is.null(outputFunc)) outputFunc <- lapply(plotlib, getOutputFunc)
if (is.null(outputFunc2)) outputFunc2 <- lapply(plotlib2, getOutputFunc)
} else {
if (is.null(outputFunc)) outputFunc <- getOutputFunc(plotlib)
if (is.null(outputFunc2)) outputFunc2 <- getOutputFunc(plotlib2)
}


## --------------------------------------------------------------------------------
## ------------------------ BUTTONS -----------------------------------------------
Expand Down Expand Up @@ -215,27 +224,26 @@ PlotModuleUI <- function(id,
## ------------------------------------------------------------------------

# Build cards or single plot

tabs_modal <- lapply(1:length(card_names), function(x) {
bslib::nav(
card_names[x],
id = card_names[x],
bslib::card_body_fill(
outputFunc(ns(paste0("renderpopup", x)),
width = width.1, height = height.1
) %>%
shinycssloaders::withSpinner()
if (cards) {
tabs_modal <- lapply(1:length(card_names), function(x) {
bslib::nav(
card_names[x],
id = card_names[x],
bslib::card_body_fill(
outputFunc[[x]](ns(paste0("renderpopup", x)),
width = width.1, height = height.1
) %>%
shinycssloaders::withSpinner()
)
)
)
})
tabs_modal <- c(tabs_modal, id = "card_selector_modal")
plot_cards_modal <- if (cards) {
do.call(
})
tabs_modal <- c(tabs_modal, id = "card_selector_modal")
plot_cards_modal <- do.call(
bslib::navs_tab_card,
tabs_modal
)
} else {
outputFunc(ns("renderpopup"), width = width.1, height = height.1) %>%
plot_cards_modal <- outputFunc(ns("renderpopup"), width = width.1, height = height.1) %>%
shinycssloaders::withSpinner()
}

Expand Down Expand Up @@ -288,27 +296,25 @@ PlotModuleUI <- function(id,
}

# Build cards or single plot

tabs <- lapply(1:length(card_names), function(x) {
bslib::nav(
card_names[x],
# inputId = card_names[x],
bslib::card_body_fill(
outputFunc(ns(paste0("renderfigure", x)),
width = width.1, height = height.1
) %>%
shinycssloaders::withSpinner()
if (cards) {
tabs <- lapply(1:length(card_names), function(x) {
bslib::nav(
card_names[x],
bslib::card_body_fill(
outputFunc[[x]](ns(paste0("renderfigure", x)),
width = width.1, height = height.1
) %>%
shinycssloaders::withSpinner()
)
)
)
})
tabs <- c(tabs, id = ns("card_selector"))
plot_cards <- if (cards) {
do.call(
})
tabs <- c(tabs, id = ns("card_selector"))
plot_cards <- do.call(
bslib::navs_tab_card,
tabs
)
} else {
outputFunc(ns("renderfigure"), width = width.1, height = height.1) %>%
plot_cards <- outputFunc(ns("renderfigure"), width = width.1, height = height.1) %>%
shinycssloaders::withSpinner()
}

Expand Down

0 comments on commit 1e1d4d4

Please sign in to comment.