Published
Edited
Sep 30, 2020
Fork of Curved lines
Insert cell
md`# A fork of curved lines`
Insert cell
chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height])
for(var iteration=0; iteration<200; iteration++){
data.forEach((curveData,i) => {
var factor = 0.23;
curveData = curveData.map(d=>[
d[0] + Math.random()*d[0]*factor - d[0]*factor,
d[1] + Math.random()*d[1]*factor - d[1]*factor + Math.random() * (-15)
])
var g = svg.append('g').attr('transform', `translate(0,${-iteration*height/200})`);
g.append('path')
.attr('stroke', 'black')
.attr('stroke-width', Math.random()*0.6 + 0.2)
.attr('fill', 'none')
.attr('d', line(curveData))
});
}
return svg.node();
}
Insert cell
data = [[[5,10],[50,5],[100,20]]]
Insert cell
line = d3.line()
.x(d=>x(d[0]))
.y(d=>y(d[1]))
.curve(d3.curveNatural)
Insert cell
height = 800
Insert cell
y = d3.scaleLinear([0,100], [height,0])
Insert cell
x = d3.scaleLinear([0,100], [0,width])
Insert cell
d3 = require("d3@6")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more