Slackbot
03/23/2023, 2:26 PMMatt Brodie
03/23/2023, 2:34 PMAllison (Observable Team)
03/23/2023, 2:59 PMd["name"]
to access properties (works for property names with spaces, hyphens, start with numbers, etc - things that break with the d.name
dot notation): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#accessing_propertiesMike Bostock
03/23/2023, 3:15 PMd["weight (lb)"]
instead of d.weight (lb)
.
In JavaScript, d.foo
is shorthand for d["foo"]
. But you can only use that shorthand when foo
is a valid JavaScript identifier. weight (lb)
is not a valid JavaScript identifier because it has a space and parens, so you have to use the long form.Matt Brodie
03/23/2023, 4:45 PM