【问题标题】:D3js SVG open lines display a fill artifact, how to fix it?D3js SVG开行显示填充神器,如何修复?
【发布时间】:2013-09-02 01:40:07
【问题描述】:

我刚刚将法语rivers_lines 添加到我的D3js 生成的SVG 中。它现在显示如下结果:

我需要在没有神器的情况下保持河流线。

数据:一个由弧组成的topojson。

CSS 代码:

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

相同的结果,一些颜色和不透明度接近于零:

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

D3 代码:

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

我的full fiddle is temporarily here。

如何解决?

【问题讨论】:

  • 问题是您的路径在不应该关闭时已关闭。这很可能是由于河流的要素类型不正确造成的。
  • 那么和shp/topojson有关吧?
  • 是的,如答案所示,您的数据可能有问题。

标签: css d3.js svg shapefile topojson


【解决方案1】:

您有一条没有任何样式的路径,这似乎是所有黑色区域的来源。它发生在湖泊小径和河流小径之间。

它看起来像这样,但它要大得多:

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

如果您使用 Firefox 并使用其 DOM Inspector,您可以指向屏幕上的某个位置,它会突出显示该元素,以便您找到导致问题的元素。

【讨论】:

  • 不是完整的解决方案,但指出了问题所在。 +1,谢谢!
  • 谢谢罗伯特。没有人能找到更好的答案。 +1 !
猜你喜欢
  • 2018-02-15
  • 2020-08-28
  • 1970-01-01
  • 2014-03-21
  • 1970-01-01
  • 1970-01-01
  • 2019-10-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多