# Basic tooltip
config <- tooltips()
# Tooltip with custom position and content
config <- tooltips(
position = "bottom",
getContent = JS("(event, items) => {
let result = `Custom Content`;
items.forEach((item) => {
result += `Type: ${item.data.description}`;
});
return result;
}")
)
# Click-triggered tooltip with custom style
config <- tooltips(
trigger = "click",
position = "bottom-left",
offset = c(15, 20),
style = list(
".tooltip" = list(
backgroundColor = "#fff",
border = "1px solid #ccc",
borderRadius = "4px",
boxShadow = "0 2px 6px rgba(0,0,0,0.1)",
padding = "10px",
maxWidth = "300px"
)
)
)
# Conditional tooltip based on node type
config <- tooltips(
enable = JS("(event, items) => {
// Only show tooltip for nodes with type 'important'
const item = items[0];
return item.type === 'important';
}"),
enterable = TRUE,
onOpenChange = JS("(open) => {
console.log('Tooltip visibility changed:', open);
}")
)
Run the code above in your browser using DataLab