Search code examples
svgd3.jstopojsonstroke-dasharray

topojson.mesh outputting incorect path? (stroke-dasharray)


I project countries borders via :

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

Some borders svg lines connects to other ones without reasons:

enter image description here

When zommed in:

enter image description here

Note: Nor coast lines nor closed polygons are messed up. I generated this data via npm topojson & natural earth shapefiles. It also seems one out of two international borders is missing around the yellow India (Pakistani, Nepalese, Cambodian borders).

# 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

What is bugging ? How could I fix it ?

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


Solution

  • Bug actually due to `style="stroke-dasharray:4,4;" on Chrome browser. "stroke-dasharray:x,y;" mess up svg path? (Chrome).