Published
Edited
Jul 17, 2019
Insert cell
md`# Circles Group Transition`
Insert cell
{
var svg = d3.select(DOM.svg(width, height))
let circles = svg.selectAll('circle')
.data(data).enter()
.append('circle')
.attr('cx', d => x(+d.x))
.attr('cy', d => y(+d.y))
.attr('r', 5)
/*
let i = 0;
while (i < levels.length - 1) {
circles.filter(d => d.group == levels[i])
.transition()
.duration(1000)
.attr('cy', 350)
Promises.delay(2000, ++i);
}
*/
let i = 0
d3.interval(function() {
drop_group(circles, i)
i++
}, 1200)
/* circles.transition()
.delay((d, i) => i * 10)
.ease(d3.easeLinear)
.duration(5000)
.attr('cy', 350) */
return svg.node();
}
Insert cell
function drop_group(selection, i) {
selection.filter(d => d.group == levels[i])
.transition()
.duration(1000)
.attr('cy', 350)
}
Insert cell
function drop_iterate(selection) {
selection.transition()
.delay((d, i) => i * 10)
.duration(1000)
.attr('cy', 350)
}
Insert cell
function drop_all(selection) {
return selection.transition()
.duration(1000)
.attr('cy', 350)
}
Insert cell
levels = ['A', 'B', 'C']
Insert cell
width = 500
Insert cell
height = 500
Insert cell
x = d3.scaleLinear()
.domain([0, d3.max(data, d => +d.x)])
.range([20, 480])
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(data, d => +d.y)])
.range([480, 20])
Insert cell
data = d3.csv('https://gist.githubusercontent.com/daranzolin/e6e40ce71ea50c5076f001ff6d304060/raw/10e538afe9b9c4c8fdf08c71e913f676fcc06d12/testdata.csv')
Insert cell
d3 = require("d3@5")
Insert cell
d3.extent(data, d => +d.y)
Insert cell
y(24)
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