Public
Edited
Aug 29, 2023
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3.interpolate(0, 17)(interpolatorValue1/100)
Insert cell
Insert cell
d3.interpolate('red', 'blue')(interpolatorValue1/100)
Insert cell
d3.interpolate([99, 0, 1],[-99, 1e6, 99])(interpolatorValue1/100)
Insert cell
d3.interpolate('1970-01-01','2020-01-01')(interpolatorValue1/100)
Insert cell
Insert cell
Insert cell
d3.interpolateString("0 men on the dead man's chest", "1000 men on the dead man's chest")(interpolatorValue2/100)
Insert cell
d3.interpolateObject({ a: -10, b: 33 },{ a: 1000, b: -33, c: 100 })(interpolatorValue2/100)
Insert cell
d3.interpolateTransformSvg('translate(100,100) scale(2)','translate(0, 0)')(interpolatorValue2/100)
Insert cell
Insert cell
d3.quantize( d3.interpolate(0, 1700), 9 )
Insert cell
d3.quantize( d3.interpolateRainbow, 9)
Insert cell
Insert cell
{
const svg = d3.create('svg')
.attr('width', 900)
.attr('height', 500)
const data = d3.range(10).map(() => ({
x: Math.random() * 900,
y: Math.random() * 500
}))
const line = d3.line()
.x(d => d.x)
.y(d => d.y)
.curve(d3.curveBasis)

const path = svg
.append('path')
.datum( data )
.attr('d', line)
.style('stroke', 'black')
.style('stroke-width', 2)
.style('fill', 'transparent')
while(true) {
const length = path.node().getTotalLength(),
int = d3.interpolate(0, length),
x = (t) => path.node().getPointAtLength(int(t)).x,
y = (t) => path.node().getPointAtLength(int(t)).y
svg.selectAll('circle')
.data([ data[0] ])
.join('circle')
.attr('cx', d => d.x)
.attr('cy', d => d.y)
.style('fill', d3.interpolateRainbow(0))
.style('stroke', 'black')
.attr('r', 20)
.transition().delay(500).duration(10000)
.attrTween('cx', () => x )
.attrTween('cy', () => y )
.styleTween('fill', () => d3.interpolateRainbow )

yield svg.node()
await Promises.tick(12000)
}
}
Insert cell
Insert cell
Insert cell
d3 = require('d3@6')
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