How to make an x axis sticky on a D3 chart?

You would need to put the x-axis in a different html element, and then use the technique in this notebook: Sticky Positioning / Fabian Iwand | Observable

There is some discussion in this post as well:

Hope that helps!