topojson.mesh输出错误的路径? (行程dasharray)

时间:2015-01-30 01:03:13

标签: svg d3.js topojson stroke-dasharray

我通过以下方式预测国家边界:

d3.json("./admin_0.topo.json", function(error, json) { 
    var L0 =  json.objects.admin_0;
//inland borders lines
    svg.append("g").attr("id","border")
        .attr("style", mesh)
    .selectAll("path")
        .data([topojson.mesh(json, L0, function(a, b) { return a !== b; })])
    .enter().append("path")
        .attr("d", path);

  //coast lines
    svg.append("g").attr("id","coast")
            .attr("style", coast)
        .append("path")
        .datum(topojson.mesh(json, L0, function(a, b) { return a == b; }))
        .attr("d", path);
});

某些边框的svg行无其他原因连接到其他行:

enter image description here

当zommed in:

enter image description here

注意:海岸线和封闭多边形也不会混乱。我通过npm topojson&生成了这些数据。天然地球形状。黄色印度(巴基斯坦,尼泊尔,柬埔寨边境)周围似乎也缺少两个国际边界中的一个。

# Download (not tested)
curl https://github.com/nvkelso/natural-earth-vector/raw/master/10m_cultural/ne_10m_admin_0_countries.shp
# shp2topojson:
topojson \
    --id-property name \
    -p name=name \
    -q 1e4 \
    --filter=small \
    -o admin_0.topo.json \
    -- admin_0=ne_10m_admin_0_countries.shp

什么是窃听?我该如何解决?

Demo#Mesh,可能与:D3js SVG open lines display a fill artifact, how to fix it?& "stroke-dasharray:x,y;" mess up svg path? (Chrome)

1 个答案:

答案 0 :(得分:1)

Bug实际上是由于`style =“stroke-dasharray:4,4;”在Chrome浏览器上。 "stroke-dasharray:x,y;" mess up svg path? (Chrome)