title: D3 Javascript plotting function
body: <p>I am trying to write a tutorial about d3 and I found couple websites that can help but with not enough details. </p>
  
  <p>I have the following code that outputs a bar chart: </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;div id="mainGraph"&gt;
          &lt;/div&gt;
  &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  
  var t = 1, // start time (seconds since epoch)
      v = 0, // start value (subscribers)
      data = d3.range(33).map(next); // starting dataset
  
   function next() {
     return {
      time: ++t,
       value: v = ~~Math.max(10, Math.min(80, Math.exp(t)))
     };
  }
  setInterval(function() {
     data.shift();
     data.push(next());
   }, 1500);
  
    var w = 40,
        h = 100;
  
    var x = d3.scale.linear()
        .domain([0, 1])
        .range([0, w]);
  
    var y = d3.scale.linear()
        .domain([0, 100])
       .rangeRound([0, h]);
  
       var chart = d3.select("body")
       .append("svg:svg")
       .attr("class", "chart")
       .attr("width", w * data.length + 10)
       .attr("height", h);
  
       chart.selectAll("rect")
       .data(data)
      .enter().append("svg:rect")
       .attr("x", function(d, i) { return x(i) + 5; })
       .attr("y", function(d) { return h - y(d.value) + 5; })
       .attr("width", w)
       .attr("height", function(d) { return y(d.value); });
  
       chart.append("svg:line")
       .attr("x1", 0)
       .attr("x2", w * data.length)
       .attr("y1", h + 5)
       .attr("y2", h + 5)
       .attr("stroke", "#000");
  
  
  
  
  
      &lt;/script&gt;           
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>The first question is what does function()</p>
  
  <p>the second question is when I try to change the set of data so i am trying to put v in function of t like v = Math.exp (t)
  this is not working and its giving me a black line only even though I changed the interval of max and min.
  Thank you.</p>