关于国家地图的 D3js 工具提示不会出现
D3js Tooltip on country MAP is not coming
工作一:
http://jsfiddle.net/2emnt8m3/17/
不工作的时候
http://ranjan720.github.io/
源代码:
https://github.com/ranjan720/ranjan720.github.io
我使用的地图图表:
var div = d3.select("body").append("div").attr("class", "tooltip").style("opacity", 0);
我使用的饼图:
var tip = d3.tip()
.attr('class', 'd3-tip')
.html(function(d) {
return d.data.population;
})
.direction('s')
svg.call(tip);
svg.selectAll(".arc")
.data(function(d) {
return pie(d.ages);
})
.enter().append("path")
.attr("class", "arc")
.attr("d", arc)
.style("fill", function(d) {
return color(d.data.name);
})
// SHOW/HIDE TOOLTIP
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
svg.append("text")
.attr("dy", ".35em")
.style("text-anchor", "middle")
.text(function(d) {
return d.State;
});
var m = d3.map(datas, function(d) {
if(d.Year == $("input[name=Year]:checked").val()){
return d.STATEUTS.toUpperCase();
}});
在鼠标悬停回调中保留以上代码行,
在var id = d3.select(this).attr('id');
这一行之前。
希望这对你有用...
如果没有要求更多。
工作一: http://jsfiddle.net/2emnt8m3/17/
不工作的时候 http://ranjan720.github.io/
源代码: https://github.com/ranjan720/ranjan720.github.io
我使用的地图图表:
var div = d3.select("body").append("div").attr("class", "tooltip").style("opacity", 0);
我使用的饼图:
var tip = d3.tip()
.attr('class', 'd3-tip')
.html(function(d) {
return d.data.population;
})
.direction('s')
svg.call(tip);
svg.selectAll(".arc")
.data(function(d) {
return pie(d.ages);
})
.enter().append("path")
.attr("class", "arc")
.attr("d", arc)
.style("fill", function(d) {
return color(d.data.name);
})
// SHOW/HIDE TOOLTIP
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
svg.append("text")
.attr("dy", ".35em")
.style("text-anchor", "middle")
.text(function(d) {
return d.State;
});
var m = d3.map(datas, function(d) {
if(d.Year == $("input[name=Year]:checked").val()){
return d.STATEUTS.toUpperCase();
}});
在鼠标悬停回调中保留以上代码行,
在var id = d3.select(this).attr('id');
这一行之前。
希望这对你有用... 如果没有要求更多。