Dictionary D3.js:将鼠标悬停在动画地图上
是否可以在此示例地图中添加鼠标悬停功能:Dictionary D3.js:将鼠标悬停在动画地图上,dictionary,animation,d3.js,Dictionary,Animation,D3.js,是否可以在此示例地图中添加鼠标悬停功能: 感谢您的建议。找到了一种方法,在应用choropleth的部分添加mouseover/mouseout。但必须使用全局标记添加工具提示: var div = d3.select("body").append("div") .attr("class", "tooltip") .style("opacity", 0); //apply choropleth d3.select("#counties").selectAll(".county
感谢您的建议。找到了一种方法,在应用choropleth的部分添加mouseover/mouseout。但必须使用全局标记添加工具提示:
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
//apply choropleth
d3.select("#counties").selectAll(".county")
.attr("fill", function (d) {
return getColor(d.properties[attributeArray[currentAttribute]], dataRange);
})
.on("mouseover", function (d) {
d3.select(this)
div.transition()
.duration(300)
div.text(d.properties.County)
.style("opacity", 1)
.style("class", "cntyLabel")
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY) + "px");
})
.on("mouseout", function (d) {
div.transition()
.duration(300)
.style("opacity", 0);
})