#' importFrom shinyBS bsCollapse, bsCollapsePanel
#'
mod_LegendColoredExprs_ui <- function(id){
ns <- NS(id)
bsCollapse(id = "collapseExample",
open = "",
bsCollapsePanel(title = "Legend of colors",
uiOutput(ns('legend')),
style = ""
)
)
}
mod_LegendColoredExprs_server <- function(id, obj, hide.white = TRUE){
moduleServer(
id,
function(input, output, session) {
ns <- session$ns
output$legend <- renderUI({
mc <- metacell.def(GetTypeofData(obj()))
tagList(
lapply(1:nrow(mc), function(x){
if (mc[x, 'color'] != 'white' || (mc[x, 'color'] == 'white' && !isTRUE(hide.white))) {
tagList(
tags$div(class="color-box",
style = paste0("display:inline-block;
vertical-align: middle;
width:20px; height:20px;
border:1px solid #000;
background-color: ",
mc[x, 'color'] , ";"),
),
tags$p(style = paste0("display:inline-block;
vertical-align: middle;"),
mc[x, 'node']),
br()
)
}
})
)
})
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.