Published
Edited
Nov 22, 2020
1 star
Insert cell
Insert cell
polyData = polynomialRegression(data)
Insert cell
data = [
{"x":1,"y":18539},{"x":2,"y":20695},{"x":3,"y":21848},
{"x":4,"y":19121},{"x":5,"y":23501},{"x":6,"y":28724},
{"x":7,"y":28061},{"x":8,"y":36222},{"x":9,"y":37756},
{"x":10,"y":38212},{"x":11,"y":31629},{"x":12,"y":32282}
]
Insert cell
polyData.coefficients
Insert cell
polynomialRegression = d3.regressionPoly()
.x(d => d.x)
.y(d => d.y / 1000)
.order(3);
Insert cell
Insert cell
Insert cell
xAxisPolynomial = d3.axisBottom(xScalePolynomial)
.tickSize(innerHeight + 30);
Insert cell
yAxisPolynomial = d3.axisLeft(yScalePolynomial)
.tickSize(innerWidth + 10);
Insert cell
linePolynomial = d3.line()
.x(d => xScalePolynomial(d[0]))
.y(d => yScalePolynomial(d[1]*1000));
Insert cell
xScalePolynomial = d3.scaleLinear()
.domain([0, 12])
.range([0, innerWidth])
Insert cell
yScalePolynomial = d3.scaleLinear()
.domain([0, 60000])
.range([innerHeight, 0])
Insert cell
Insert cell
Insert cell
base = Math.min(width, 500);
Insert cell
innerWidth = base - margin.left - margin.right;
Insert cell
innerHeight = base - margin.top - margin.bottom;
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more