Tidy Stacked Area Chart | D3 | Observable
ojs
ojs
ojs
ojs
Author
Mike Bostock
@mbostock
Visualization toolmaker. Founder
@observablehq
. Creator
@d3
. Former
@nytgraphics
. Pronounced BOSS-tock.
Comments (3)
Daniel Lucazeau
Aug 4, 2022
The stack calculation does not seem to work if any values are set to zero. I have tried with this cell: unemployment.forEach((d, idx) => { if (idx % 170 === 0) { d.unemployed = 0; } })
Fil
Aug 5, 2022
It's because it defaults to offset: d3.stackOffsetDiverging, which puts zeros on the x axis. You can use `offset: d3.stackOffsetNone` to fix.
Daniel Lucazeau
Aug 5, 2022
This fix it. Thanks
Reply
Add comment
Subscribe to notifications
© 2026 Observable, Inc.
Terms of service
Privacy policy
Product
About
Pricing
Documentation
Release notes
Contact us
Open source
Notebook Kit
Plot
D3
Community
Public
Forum
Bluesky
YouTube
X
Observable
Sign up
D3
Mike Bostock
15
Reply
Add comment
Subscribe to notifications
54
Tidy Stacked Area Chart | D3 | Observable