block by jalapic b829b238665960aa6d4840cb30fbd8b8

Basic Data Update & Linear Regression

Full Screen

A basic scatterplot with variable axes. Uses d3’s update pattern to modify the axis values as well as the x y position of the points on the plane.

A linear regression is then calculated and plotted for the data set being visualized. The slope, y-intercept and rSquared values are calculated from code found here: http://bl.ocks.org/benvandyke/8459843

A random generator is then used to fetch an x value, plug that into the y=mx+b format and give an array of points which, when plotted, aproximates the linear regression. The transition on the linear regression is a bit wonky, I stil need to look into that, feel free to comment if you know where I went wrong there.

May want to implement this: https://bocoup.com/weblog/improving-d3-path-animation

forked from mph006‘s block: Basic Data Update & Linear Regression

Another resource here

index.html

data.js

regression.js

style.css