Custom Hue Picker | Casey Labrack | Observable
Author
Casey Labrack
@shastabolicious
Comments (3)
chris willis
Nov 30, 2020
D3@6 breaks your drag event (d3.event.x). You need to pass the event listener like this: Before: d3.select(context.canvas) .call(d3.drag() .on("start drag end", d => { context.clearRect(0, 0, w, h) render(hue(d3.event.x)) context.canvas.value = hue(d3.event.x) context.canvas.dispatchEvent(new CustomEvent('input')) }) ) After: d3.select(context.canvas) .call(d3.drag() .on("start drag end", (event, d) => { context.clearRect(0, 0, w, h) render(hue(event.x)) context.canvas.value = hue(event.x) context.canvas.dispatchEvent(new CustomEvent('input')) }) ) Reference:
https://observablehq.com/@d3/d3v6-migration-guide#events
Thanks for the good work!
Casey Labrack
Nov 30, 2020
oh wow, you're right. this is very helpful! thank you very much
chris willis
Nov 30, 2020
You're welcome. I'm not much of a javascript expert, but I got lucky on this one ;-)
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
Explore
Forum
Bluesky
YouTube
X
2
Follow
Follow
Custom Hue Picker | Casey Labrack | Observable