admin管理员组

文章数量:1425665

If I do this, the axis text's fill is also set to none.

     graph.append("g")
        .attr("class", "x axis")
        .attr("fill", "none")
        .call(rrd3.xAxis);

How can I set fill to none for the path and the line, but not the text. I want to do this with javascript through d3. I can get it working by editing my stylesheet but that's not how I want to do it.

If I do this, the axis text's fill is also set to none.

     graph.append("g")
        .attr("class", "x axis")
        .attr("fill", "none")
        .call(rrd3.xAxis);

How can I set fill to none for the path and the line, but not the text. I want to do this with javascript through d3. I can get it working by editing my stylesheet but that's not how I want to do it.

Share Improve this question asked Jan 20, 2015 at 18:17 JakePJakeP 3273 silver badges14 bronze badges 6
  • Move the code the to where you create paths and lines. As it stands all child elements of that <g> will inherit the respective properties. – Sirko Commented Jan 20, 2015 at 18:21
  • That was my first thought but I never actually create the path and lines. I create the axis which seems to have all those things built in. – JakeP Commented Jan 20, 2015 at 18:23
  • The cleanest approach would be to use stylesheets. Without them, no easy/clean way es to my mind. – Sirko Commented Jan 20, 2015 at 18:25
  • Maybe that is the only way. For now, I'll keep it in my stylesheet but I'll leave this question open in case someone can think of a way. – JakeP Commented Jan 20, 2015 at 18:26
  • There are ways ... you could select any path and line element below the appended <g> and apply the styles to those, but that's far from clean ... – Sirko Commented Jan 20, 2015 at 18:33
 |  Show 1 more ment

1 Answer 1

Reset to default 5

Select the elements you want to change explicitly:

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

本文标签: