Public
Edited
Apr 7, 2019
2 forks
41 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
axis = function(data, line, circles) {
let smallest
let top
// find the middle of the smallest section of the middle area
data.forEach(function(section){
if(!smallest || smallest > section.top - section.bottom) {
smallest = section.top - section.bottom
top = section.bottom + (smallest/2) - 1
}
})
// axis line transition
line
.attr('y1', height/2).attr('y2', height/2)
.attr('opacity', '0')
.transition()
.duration(500)
.ease(d3.easeCircle)
.attr('y1', y(top)).attr('y2', y(top))
.attr('opacity', '0.8')
// axis circle transition
circles
.attr("cy", y(top))
.attr('opacity', '0')
.transition()
.delay(500)
.duration(300)
.ease(d3.easeCircle)
.attr('opacity', '0.8')
}
Insert cell
Insert cell
area = function(type) {
return d3.area()
.curve(d3.curveMonotoneX)
.x(d => x(d.name))
// the bottom y possition of each area
.y0(
type==='no'?
height/2 :
// the inner stream should always be the smaller one.
d => y(
type==='under' || (type!=='over' && d.bottom > d.outerBottom) ?
d.bottom : d.outerBottom
)
)
// the top y position of tach area
.y1(
type==='no'?
height/2 :
// the inner stream should always be the smaller one.
d => y(
type==='under' || (type!=='over' && d.top < d.outerTop) ?
d.top : d.outerTop
)
)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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