D3js SVG open lines display a fill artifact, how to fix it?

微笑、不失礼 提交于 2019-12-02 06:52:14

问题


I just added French rivers_lines to my D3js generated SVG. It now display a result like :

I need to keep the river lines without the artifact.

Data : a topojson made of arcs.

CSS code:

.rivers { 
  fill: none;
  fill-opacity: .1;
  stroke-width:1px;
  stroke: #C6ECFF;
 }

same result with some colors and opacity near zero:

 fill: #FF0000;
 fill-opacity: .1;

D3 code:

    rivers = topojson.feature(fra, fra.objects.rivers),

    //Append rivers
    svg.append("path")
        .datum(rivers)
        .attr("d", path)

    svg.selectAll(".rivers")
        .data(topojson.feature(fra, fra.objects.rivers).features)
      .enter().append("path")
        .attr("class", function(d) { return "rivers"; })
        .attr("data-name-en", function(d) { return d.properties.name; })
        .attr("d", path);

My full fiddle is temporarily here.

How to fix that ?


回答1:


You have a path without any style which seems to be the source of all the black areas. It occurs just between the lakes paths and the rivers paths.

And it looks like this but it's much much bigger:

<path d="M254.68465149579959,297.3979576500094L252.63102536206452,297.7622166535384L251.8095749085707,297.7622166535384...

If you use Firefox and use its DOM Inspector you can point to a place on the screen and it will highlight the element so you can find the one which is causing an issue.



来源:https://stackoverflow.com/questions/18514039/d3js-svg-open-lines-display-a-fill-artifact-how-to-fix-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!