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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -