Dictionary 如何在d3中仅呈现topojson的一部分

Dictionary 如何在d3中仅呈现topojson的一部分,dictionary,d3.js,topojson,Dictionary,D3.js,Topojson,我有一个topojsonfile,它包含了印度所有的地区。我只想渲染特定州的地区。我不知道该怎么做 这是我的初始代码它呈现所有地区: 这是topojson文件的快照 至少要提一下投票反对的理由 var district_geo_obj = topojson.feature(district, district.objects.india_district); var district_projection = d3.geoMercator() .fitSize([

我有一个topojsonfile,它包含了印度所有的地区。我只想渲染特定州的地区。我不知道该怎么做

这是我的初始代码它呈现所有地区:

这是topojson文件的快照


至少要提一下投票反对的理由
    var district_geo_obj = topojson.feature(district, district.objects.india_district);
    var district_projection = d3.geoMercator()
        .fitSize([width/2, width/2], district_geo_obj);
    var district_path = d3.geoPath().projection(district_projection);

    map_svg.selectAll("path")
        .data(district_geo_obj.features)
        .enter().append("path")
        .attr("d", district_path)
        .attr('class', 'map-margin-const')
        .style('fill', function(d) {
            return 'red';
        })
  var districts = ["aaa", "bbb", "ccc", "ddd"];

  map_svg.selectAll("path")
    .data(district_geo_obj.features)
    .enter().append("path")
    .attr("d", district_path)
    .attr('class', 'map-margin-const')
    .style('fill', function(d) {
        return 'red';
    }).style("stroke-width", function (d, i) {
                    if (districts.indexOf(d["properties"]["NAME_1"]) > -1 ) return "1px";   // Not sure about the syntax. But this should do
                    else return "0px";
                })