0
有沒有一種方法,以添加d3.tip與d3.tip添加鼠標懸停效果
假設我一個mousover效果有這個
var tip = d3.tip()
.attr("class", "d3-tip")
.html(function(d) {
return d.properties.xy
});
svg.call(tip);
var feature = g.selectAll("circle")
.data(data.features)
.enter()
.append("circle")
.attr("r", function (d) {
d.properties.xy
})
.style("fill", "red")
.attr("fill-opacity", 0.5)
.on("mouseover", tip.show)
.on("mouseout", tip.hide);
這讓我通過d3.tip提示。但是,如果我想要一些效果,像這個鼠標懸停怎麼辦?
feature.on("mouseover",function(d) {
d3.select(this)
.transition()
.ease("elastic")
.duration(500)
.attr('r', function (d){
return (10 * d.properties.xy)
})
.style("stroke", "black")
.style("stroke-width", 2)
});
有沒有辦法將這兩種方法結合起來?
查看JSfiddle 這裏缺少的是d3.tip在mouseover上的工具提示,就像這個example一樣!
還沒有實現鼠標移開所以你會不得不做一個,很容易:)) – thatOneGuy
真棒。謝謝你的支持。讓我們刪除問題下面的所有評論?! – Stophface
沒問題,當你第一次問的時候很忙,所以花了一天左右才能正確回覆:) – thatOneGuy