title: Javascript OOP, getters, setters, run - D3.js - make graph resuable by option settings
body: <p>I tried myself but oviously I am not good enough to make this work :-) What I would like to achieve is similar to Mike's reusability talks - <a href="http://bost.ocks.org/mike/chart/" rel="nofollow">http://bost.ocks.org/mike/chart/</a> :</p>
  
  <pre><code>marbles = new Marbles();
  marbles.width();//getter, setter
  marbles.height();//-||-
  ...etc
  marbles.run();//run the code
  </code></pre>
  
  <p>Code is example is shown below. Could someone help me please? I know how to make classes and OOP in Java or PHP, but pure JS is not my area of expertise :-)</p>
  
  <p>I have this code:</p>
  
  <pre><code>//initialize on (menu click)
  jQuery(document).ready(function(){
  
  
         marbles();
  
  
      });
  });
  </code></pre>
  
  <p>with variables and main function:</p>
  
  <pre><code>function marbles(){
      var height = 500,
          width = 1000;    
  
  
         var path = "";
  </code></pre>
  
  <p><strong>..another vars (about 15)</strong></p>
  
  <pre><code>       var force = d3.layout.force()        
            .size([width, height]);
         //foci to be set for relation type positioning and nodes placing
  
         var links = force.links(),
            nodes = force.nodes();
  
  
        run();
  
       //graph starts here by loading data - d3.xml
       function run (rootNode){
  
       begin();
  
  
       }
  
      //internal timer function - adding nodes one at the time
      function begin(clickedNode){  
  
     }
  
     //classical update function
     function update() {
  
     }
  
  }
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Lukas</p>