title: Updating graph as I drag a point around
body: <p>I am making a line of best fit app using d3 in which I want the line of best fit to update as I drag the points around. I got it work so that when your drag ends, the line updates by itself. However, when it comes to actually updating as the point is being dragged, I am unable to do so.</p>
  
  <p>Here is my drag function:</p>
  
  <pre><code> var move =  d3.behavior.drag()
                  .on("drag",drag)
                  .on("dragend",function(){
                      dict.length = 0;
                      var dragPoint = d3.select(this);
                      var newX = x_scale2(parseInt(dragPoint.attr("cx")));
                      var newY = y_scale2(parseInt(dragPoint.attr("cy")));
  
                      model.replace_point(dragPoint.attr("id"),newX,newY);
                      updateDisplay();
  
  
              });
  
    function drag(){
        var dragPoint = d3.select(this);
        dragPoint
      .attr("cx",function(){return d3.event.dx + parseInt(dragPoint.attr("cx"));})
      .attr("cy",function(){return d3.event.dy +parseInt(dragPoint.attr("cy"));})
          }
  </code></pre>
  
  <p>** Any help on how to accomplish my goal would be appreciated ** </p>