I have reviewed a few posts to have a tooltip show the information when hovering over a cell data, but those didn’t seemed to address my needs.
I managed to put something together (without really understanding the code but hey it works) that is able to show the tooltip when hovering over a specified cell of a column. In this case, the tooltip will have a black background, with white font text, and that the column header that I want the tooltip to show when hover is the “Review” column in the table.
gb.configure_column(field="Review", maxWidth=400, tooltipField="Review", tooltipComponent = JsCode("""
class CustomTooltip {
eGui;
init(params) {
const eGui = (this.eGui = document.createElement('div'));
const color = params.color || 'black';
const data = params.api.getDisplayedRowAtIndex(params.rowIndex).data;
eGui.classList.add('custom-tooltip');
//@ts-ignore
eGui.style['background-color'] = color;
eGui.style['color'] = 'white';
eGui.style['padding'] = "5px 5px 5px 5px";
eGui.style['font-size'] = "15px";
eGui.style['border-style'] = 'double';
this.eGui.innerText = data.Review;
}
getGui() {
return this.eGui;
}
}"""))
An example of how it looks like:
Am using streamlit==1.27.2 and streamlit-aggrid==0.3.4.post3
Hope it helps anyone who might be looking to implement something similar.