使用D3,如何设置轴路径和线的属性(“填充”,“无”),但不设置文本(无需编辑样式表)

Jak*_*keP 4 javascript d3.js

如果我这样做,轴文本的填充也将设置为无。

     graph.append("g")
        .attr("class", "x axis")
        .attr("fill", "none")
        .call(rrd3.xAxis);
Run Code Online (Sandbox Code Playgroud)

如何将路径和行的填充设置为无,但文本不设置为无。我想通过 d3 使用 javascript 来完成此操作。我可以通过编辑样式表来使其工作,但这不是我想要的方式。

Lar*_*off 5

选择您要明确更改的元素:

var axG = graph.append("g")
    .attr("class", "x axis")
    .call(rrd3.xAxis);
axG.selectAll("path").attr("fill", "none");
axG.selectAll("line").attr("fill", "none");
Run Code Online (Sandbox Code Playgroud)