Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 重置d3中的填充颜色_Jquery_Svg_D3.js - Fatal编程技术网

Jquery 重置d3中的填充颜色

Jquery 重置d3中的填充颜色,jquery,svg,d3.js,Jquery,Svg,D3.js,我用d3创建了一个地球仪。我想改变国家的填充颜色,这取决于它们是否在一个名为“unrepresented”的数组中。但我无法改变填充颜色。请问我有错误的语法吗 d3.json("world-countries.json", function(collection) { feature = svg.selectAll("path") .data(collection.features) .enter().append("s

我用d3创建了一个地球仪。我想改变国家的填充颜色,这取决于它们是否在一个名为“unrepresented”的数组中。但我无法改变填充颜色。请问我有错误的语法吗

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");;
                }
             }
          });


});
d3.json(“world countries.json”),函数(集合){
feature=svg.selectAll(“路径”)
.数据(收集.特征)
.enter().append(“svg:path”)
.attr(“d”,剪辑)
.attr(“id”,函数(d){return d.id;})
.on(“鼠标悬停”,pathOver)
.on(“mouseout”,pathOut)
。开启(“点击”,点击);
feature.append(“svg:title”)
.text(函数(d){return d.properties.name;});
feature.each(函数(){
thisOne=$(this.attr('id');

for(var i=0;i
thisOne
是代码中节点的ID——您不能在该节点上设置样式。以下代码应该可以工作:

d3.select(this).style("fill", "#000000");

我做了那个更改,但现在它抛出了一个错误:error:Problem parsing d=“”,这是一个不相关的错误。你能发布一个完整的工作示例吗?不,我的代码还有其他问题。你的答案是正确的。谢谢,拉尔斯!