d3.js - How to avoid empty DOM elements in code? -
how can avoid creation of empty elements in svg code? in graph drawn d3, specific nodes circle , other have text.
svg.append("circle").filter(function(d) { return d.haslabel; }) .style("fill", "white") .attr("r", 8) .attr("cx", function(d) { return xscale(d.x) }) .attr("cy", function(d) { return yscale(d.y) });
it works somehow, nodes haslabel true show circle, looking @ html page source code see nodes haslabel false have . there way avoid this?
just move append
after filter
, so..
svg.filter(function(d) { return d.haslabel; }) .append("circle") .style("fill", "white") .attr("r", 8) .attr("cx", function(d) { return xscale(d.x) }) .attr("cy", function(d) { return yscale(d.y) });
Comments
Post a Comment