title: d3. change color of nodes individual depending on array content
body: <p>Im working with <code>d3</code> since a few days. I chose the <a href="http://mbostock.github.io/d3/talk/20111018/tree.html" rel="nofollow">collapse tree</a> to show a layer structure of another project. The <code>d3</code> functions in this example are exactly mine. Only changes i did that i ask for the nodes in my project to show them in a tree instead of using <code>flare.json</code>.</p>
  
  <p>So i asked for the status ( if its enabled or not). See the code below. If a Layer is enabled the circle for the node shall be green. If its not enabled the circle of the node should be red. The status is given to an array. </p>
  
  <pre><code>var statusarray = [];
  for (i = 0; i &lt; operational.children.length; i++ ) {
  
      //var status to save children enabled-status at [i]
      var status = operational.children[i].get("enabled");
  
      //test output for operational.children at [i]
      console.log(operational.children[i].id + " steht auf " + status) ;
  
      //Create Array (statusarray) for status with length of operational children (saves true and false)
      statusarray[i] = status;
  }
  </code></pre>
  
  <p>The array is build like that: <code>[true, true, true, false, true , false ....]</code></p>
  
  <p>With that data i want to manipulate the circles which fit for the attributes.</p>
  
  <p>EDIT:</p>
  
  <p>My data in the java-script is saved here:</p>
  
  <pre><code>  var myjson = {
                      "name": main.id,
                      "children": [
                          {
                              "name": glasspane.id,
                              "children": [
                              ]
                          },
                          {
                              // get id of operational layer
                              "name": operational.id,
                              "children": [
                              ]
                          },
                          {
                              "name": base.id,
                              "children": [
                              ]
                          }
                      ]
                  };
  </code></pre>
  
  <p>i begin to fill it with:</p>
  
  <pre><code> for (i = 0 ; i &lt; main.children.length; i++) {
                   // Array for children from root
                     var layer = main.children;
                   // Create childrn from Layers in Arrays and fill myjson with them
                     d_array.forEach(layer[i].children, function (ArrayElement) {
                         myjson.children[i].children.push({"name": ArrayElement.id});
                     }, this);
                    }
  </code></pre>
  
  <p>Any help is appreciated!!!</p>