Apologies, I couldn’t think of anything better to call the problem I am seeing. It is a simple problem but I am new to observable and also JS which doesn’t help.
The chart loads however I find that when the mouse activates the line charts it activates it about 1 inch above where the line actually is. Of course in the example online it is working, and I have not changed any code so I am wondering what could have gone wrong in-between. I am wondering whether anyone else has seen this, or is it only me?
When I embed just the cell and not the whole workbook, the chart works fine, however this is not sufficient for what I am trying to do.
Thanks for the reply, I appreciate it! No I literally have just chucked the downloaded code onto Apache, there is no other code. The only style-sheet is the one included: inspector.css. I deleted the css file and it didn’t seem to make much difference so it could be that it isn’t loading it in the first place?
I see it too! I just downloaded the notebook and see the same thing. In function moved(), the line const ym = y.invert(d3.event.layerY); is looking at the mouse event and finding the point in data-space that it corresponds to. When you view the notebook on observablehq.com, layerY is measuring relative to the top of the cell, but when you view the downloaded notebook, it’s measuring relative to the top of the whole page.
d3.mouse measures position relative to some container. So you can replace these two lines in the function moved
const ym = y.invert(d3.event.layerY);
const xm = x.invert(d3.event.layerX);
Let me know if that works. I’ve suggested it as a change on the d3 notebook; it should work equally well on Observable and locally in the downloaded notebook. Good catch!
Thanks Tophtucker!!! I just got around to testing this and it works. Thanks again for your support I super appreciate the community when it comes to things like this!