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
1 Answer
Reset to default 5Select 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");
本文标签:
版权声明:本文标题:javascript - With D3, how can I set attribute ("fill", "none") of axis path and line, but no 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745390339a2656568.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论