If I have a function which computes multiple attributes to set on each SVG element in a selection, based on both bound data and additional outside variables, what is the most idiomatic way to call the function once per datum and then update all of the attributes at once?
I notice d3-selection-multi. Is that generally the best approach? How would one go about importing both d3 and that in an observable notebook? I tried d3 = require("d3", "d3-selection-multi") but that doesn’t seem to cut it. I get an error that attrs isn’t a function. (I admit I still don’t really understand the ins and outs of require, etc.)
Unfortunately, you can’t mix-and-match D3 modules with the d3 default bundle using require. If you want to use d3-selection-multi, you must import the D3 modules separately:
I’m having trouble getting either this one – d3 = require("d3-selection", "d3-selection-multi") – or the datum version to work. I’ll keep fiddling with it.