js/css duo for bootstrap style Tooltips and Popovers.
The tooltip function attaches event listeners to selections that go and display bootstrap tooltips or popovers when the specified events are detected.
An example of how to use it:
selection.tooltip(function(d,i){
return {
content:{
type: "tooltip" //Other option: popover
text: d.title
//For popovers
content: svg //A d3 svg element
title: "A title"
},
detection:{
type: "shape" //Work in progress. Check back later
},
placement:{
type: "fixed"
gravity: "right" //left,top,bottom
position: [d.x,d.y]
},
mousemove: false
};
})
Viola! Tooltips! Popovers!
- Add in better defaults.
- Get the animated fading going.
- Divorce tooltips from popovers. Make them both call the same/ positioning and eventing method, but have them pass in the created html.
- Get easy voronoi detection working without breaking everything.
- Write some tests.
- Use it in production.
Public domain.