MHS
MHS

Reputation: 931

i change the "class" attribute of a node that exist in SVG, but not applied ! why?

i change the "class" attribute of a node that exist in SVG, but not applied !

this is my Code (in my Directive angularJs):

  node = node.data(force.nodes(),function (d) { return d.id; });
  var newNode = node.enter()
         .append("g")
         .attr("display",function(d) {return d.dis })
         .attr("class",function(d){
                return  "node " + d.class;
         })

why?

TNX

Upvotes: 0

Views: 100

Answers (1)

tomtomtom
tomtomtom

Reputation: 1522

Looks like you are changing the "class" attribute of a "g" inside the node, and not the class of the node itself. To change the class of the node you can simply do:

var newNode = node.attr("class",function (d) { return  "node " + d.class; })

Upvotes: 1

Related Questions