Published
Edited
Mar 25, 2021
26 stars
Insert cell
Insert cell
vl.data(data)
.transform(
vl.window(vl.row_number().as('series')), // add index for each series
vl.flatten('data'), // flatten each series array to individual data points
vl.groupby('series').window(vl.row_number().as('index')) // add index for each point
)
.mark({type: 'line', fill: 'white', stroke: 'black', strokeWidth: 1})
.encode(
vl.x().fieldQ('index').axis(null),
vl.y().fieldQ('data').scale({range: [step, -overlap * step]}).axis(null),
vl.row().fieldN('series').spacing(0).header({title: null, labelPadding: 0, labelFontSize: 0})
)
.width(width) // facet cell width
.height(step) // facet cell height
.bounds('flush') // use facet cell height for layout, not the full mark bounds
.padding(0) // no chart padding
.config({view: {stroke: null}}) // no cell borders
.render()
Insert cell
Insert cell
step = 8 // base height for each data series
Insert cell
overlap = 16 // overlap scale factor for data series
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