1

Hello guys i am creating r shiny dashboard,

I want to add color shade like heat map.

I go with this link reference 3 Style A Full Table but dont know how to use it in my code with blue color.

showRecordColumns <- c('Supplier','# Parts at Risk' , 'DAM Score', 'REL Score', 'AGI Score', 'RES Score')
  SDRMSketch = htmltools::withTags(table(
    class = 'table table-striped table-hover',
    thead(
      tr(
        th(colspan = 1, ' '),
        th(colspan = 2, 'Buyer: Suilian', class="sdrm-table-head-buyer"),
        th(colspan = 3, 'Risk Matrix', class="sdrm-table-head-risk-matrics")
      ),
      tr(
        lapply(showRecordColumns, th)
      )
    )
  ))
output$SDRM <- DT::renderDataTable(DT::datatable(merged[,showRecordColumns],
                                      container = SDRMSketch,
                                      rownames = FALSE,
                                      extensions = 'Buttons',
                                      callback=JS('$(".buttons-csv").addClass("btn btn-inline btn-dark-outline"); return table;'),
                                      options = list(
                                                      paging = TRUE,
                                                      searching = TRUE,
                                                      fixedColumns = TRUE,
                                                      autoWidth = TRUE,
                                                      ordering = TRUE,
                                                      dom='Bftrip',
                                                      buttons = list(
                                                        list(extend = "csv", 
                                                             text = "Download Current Page", 
                                                             filename = "SDRM_page",
                                                             class = "btn",
                                                             exportOptions = list(
                                                               modifier = list(page = "current")
                                                             )
                                                        ),
                                                        list(extend = "csv", text = "Download Full Results", filename = "SDRM_data",
                                                             exportOptions = list(
                                                               modifier = list(page = "all")
                                                             )
                                                        )
                                                      )
                                                      )  
                                              ) %>% formatRound(c(3:6), 2)
                                              %>% formatStyle(c(2), background = styleColorBar(range(0:100), 'lightblue'))
                                      )

}

Current data table result displayed like

enter image description here

Apply color range on only last four column and lower value higher color density. Want to represent lower value means danger.

Expected Result should be like this.

enter image description here

Nirav Prajapati
  • 265
  • 2
  • 15
  • Hi, please provide a [minimal and reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – bretauv Jun 04 '20 at 18:48
  • Thanks @bretauv, its solved by this changes ```brks <- quantile(df, probs = seq(.01, .95, .02), na.rm = TRUE) clrs <- round(seq(255, 40, length.out = length(brks) + 1), 0) %>%{paste0("rgb(255,", ., ",", ., ")")} datatable(df) %>% formatStyle(names(df), backgroundColor = styleInterval(brks, clrs))``` – Nirav Prajapati Jun 05 '20 at 02:24

0 Answers0