Searching for a range slider (not available at Jeremy’s input bazare) , I came across d3-simple-slider, which I almost have working:
The problem seems to be that the demo examples, as hosted on bl.ocks refers to both the d3-simple-slider module and d3 as d3. I give the module an explicit name (d3_slider) and it appears in my notebook, but it’s doesn’t work.
I tried linking d3 and the d3-simple-slider module as follows, but this doesn’t seem to ‘link’ both d3 and the module under the name d3:
I haven’t tried to make your notebook work yet, but I think the solution to the require question is just to use multiple parameters in require (see the discussion here):
Thanks Bryan! That method of requiring does get around the linking of d3 and the module. The notebook still doesn’t work with this fix though not sure why.
Likely because d3-simple-slider accesses d3.event in a different scope than the one used by d3. As a result, when d3 sets d3.event, d3Selection.event inside the slider scope is still null.
Woah, @mootari - Perfect answer, and yet I’ll one I’ll have to research before I can pretend to understand Still - THANK YOU! I’ll see what I can do to figure out what this means… and why the behavior would differ in Observable vs. the HTML examples.
You’re very welcome! And remember that the require function is actually d3-require (in case you want to look up the documentation).
As for debugging issues like these, my strategy usually involves opening the dev tools and enabling “Pause on exceptions”. This will give you the opportunity to inspect the scope in which the error occured, as well as the function calls leading up to the error.