0
我正在使用d3创建地球仪。我想要改变国家的填充颜色,取决于它们是否在一个名为“无代表性”的数组中。但我无法改变填充颜色。我有错误的语法吗?重置d3中的填充颜色
d3.json("world-countries.json", function(collection) {
feature = svg.selectAll("path")
.data(collection.features)
.enter().append("svg:path")
.attr("d", clip)
.attr("id", function(d) { return d.id; })
.on("mouseover", pathOver)
.on("mouseout", pathOut)
.on("click", click);
feature.append("svg:title")
.text(function(d) { return d.properties.name; });
feature.each(function(){
thisOne = $(this).attr('id');
for (var i=0; i<unrepresented.length; i++){
if ($(this).attr('id') == unrepresented[i]) {
thisOne.style("fill", "#000000");;
}
}
});
});
我做了改变,但现在它引发错误:错误:问题解析d =“” – LauraNMS
这是一个无关的错误。你可以发布一个完整的工作示例吗? –
不,我的代码还有其他问题。你的回答是对的。谢谢,拉尔斯! – LauraNMS