I'm facing a challenge with my Shiny app's DataTable, and I hope someone here can provide some insights.
Goal: I wish to display data in my DataTable where each cell has an associated tooltip to display related data. Additionally, I want the background color of the cell to be conditionally formatted based on its value.
What I've Tried:
Tooltips: I've managed to display tooltips using
dplyr::mutate( stat_with_tooltip = paste0( '<span title="Related data: ', relatedData, '%">', .data[[stat]], '</span>' )
This renders the tooltip as expected.
Conditional Formatting: Without tooltips, I can achieve conditional formatting with the following:
DT::formatStyle(columns = 2:5, backgroundColor = DT::styleInterval(10, c('red', 'green'))
Problem: When I combine both the tooltip and conditional formatting, things break because the
formatStyle function can't work on the HTML string from the tooltip.
Ask: Has anyone encountered a similar problem or have a solution that allows both tooltips and conditional formatting in a Shiny DataTable?
Any help or pointers would be much appreciated!