Vega tooltip with d3-tip
LakshmiVSeelam opened this issue · 2 comments
LakshmiVSeelam commented
Hello,
I am trying to use d3-tip to create custom tooltip in vega, can anyone suggest me if there is any work around or if anyone have done such before?
Please share your suggestions
Thank You
domoritz commented
You can use the Vega tooltip handler without this extension.
LakshmiVSeelam commented
Even with custom vega tooltip, the output I wanted is not achieved, hence tried to use d3-tip.
Anyways found the way to use d3-tip to create custom tooltip as required. Pasting code below:
var view = new vega.View(vega.parse(spec))
.renderer('svg')
.logLevel(vega.Warn)
.initialize("#chart")
.hover()
.run()
var tip = d3.tip()
.attr('id','customTooltip')
.attr('class', 'd3-tip')
.direction(function(d) {
//code that returns direction (n/s/e/w/se/sw/ne/nw)
})
.html(function(d){
return '....'
// html code to be returned
});
var vis = d3.select('#chart svg');
vis.call(tip)
vis.selectAll('path') //generated svg elements from vega on which tooltip has to be shown
.on('mouseover', tip.show)
.on('mouseout', tip.hide)