Some d3-scaleordinal exemple not working using d3@5

I’m trying to reproduce the exemple of Map for range and domain in Observable documentation ( :

atoms = new Map([["C", 12], ["H", 1], ["O", 16]])
colors = new Map([["C", "black"], ["H", "white"], ["O", "blue"]])

m = d3.scaleOrdinal()


Using d3 = require("d3-scale@3", "d3-scale-chromatic@1", "d3-shape@1", "d3-array@2") it works, but in my observable notebook i use d3@5 and this exemple return “undefined”

What is the equivalent of this exemple in d3@5 ?

the newest versions accept Map Iterators as inputs, if you’re using d3@5 you can try this

    m = d3
1 Like