代码之家  ›  专栏  ›  技术社区  ›  yavg

“d3.selectAll().style()”不将样式应用于所选元素,但在此选择范围内,如果有效,则使用“d3.select(this.style()”

  •  -1
  • yavg  · 技术社区  · 5 年前

    使用这个css规则,我可以将不透明度设置为svg中的一个元素。

    enter image description here

    #graph4 > svg  g.c3-chart-bar.c3-target.c3-target-data3{
        opacity: 0.3 !important;
    }
    

    但在我的脚本中,这种代码不透明度不适用。

    setTimeout(()=>{
      d3.selectAll("#graph4 > svg g.c3-chart-bar.c3-target.c3-target-data3").style("opaciy",0.3) //not works
    },2000)
    

    但如果适用的话我会这么做。为什么?

    setTimeout(()=>{
      d3.selectAll("#graph4 > svg g.c3-chart-bar.c3-target.c3-target-data3").style("opaciy",function(){
        d3.select(this).style("opacity",0.3); //it works
        return "";
      });
    },2000)
    
    1 回复  |  直到 5 年前
        1
  •  0
  •   Rob Moll    5 年前

    看起来不透明在几个地方拼错了(不透明)。