title: D3.js linear regression
body: <p>I searched for some help on building linear regression and found some examples here:<br> 
  <a href="https://stackoverflow.com/questions/13590922/how-can-i-use-d3-js-to-create-a-trend-exponential-regression-line">nonlinear regression function</a><br>
  and also some js libraries that should cover this, but unfortunately I wasn't able to make them work properly:<br>
  <a href="http://macwright.org/simple-statistics/docs/simple_statistics.html#section-19" rel="nofollow noreferrer">simple-statistics.js</a> and this one: <a href="https://github.com/Tom-Alexander/regression-js" rel="nofollow noreferrer">regression.js</a><br>
  With <code>regression.js</code> I was able to get the <code>m</code> and <code>b</code> values for the line, so I could use <code>y = m*x + b</code> to plot the line that followed the linear regression of my graph, but couldn't apply those values to the line generator, the code I tried is the following:</p>
  
  <pre><code>d3.csv("typeStatsTom.csv", function (error, dataset) {
  //Here I plot other stuff, setup the x &amp; y scale correctly etc. 
  //Then to plot the line:
  
          var data = [x.domain(), y.domain()];
          var result = regression('linear', data);
          console.log(result)
          console.log(result.equation[0]);
          var linereg = d3.svg.line()
                          .x(function (d) { return x(d.Ascendenti); })
                          .y(function (d) { return y((result.equation[0] * d.Ascendenti) + result.equation[1]); });
          var reglinepath = svg.append("path")
                              .attr("class", "line")
                              .attr("d", linereg(dataset))
                              .attr("fill", "none")
                              .attr("stroke", "#386cb0")
                              .attr("stroke-width", 1 + "px");
  </code></pre>
  
  <p>The values of result are the following in the console:</p>
  
  <pre><code>    Object
        equation: Array[2]
          0: 1.8909425770308126
          1: 0.042557422969139225
        length: 2
        __proto__: Array[0]
        points: Array[2]
        string: "y = 1.89x + 0.04"
        __proto__: Object
  </code></pre>
  
  <p>From what I can tell in the console I should have set up the <code>x</code> and <code>y</code> values correctly, but of course the path in the resulting svg is not shown (but drawn), so I don't know what to do anymore. <br>Any help is really really appreciated, even a solution involving the <code>simple.statistics.js</code> library would be helpful! <br>Thanks!</p>