6.4 Translating from D3 to Observable
See Day 27
Some points worth mentioning:
You can write codes involving multiple variables by including them in curly brackets. If you don’t use curly brackets, you have to dedicate one cell to each variable. See this example if you don’t know what “dedicating one cell to each variable” means.
In the book, you normally write
var w = 600
. However, nowlet
andconst
are preferred. Read here and here for explanations.To show the results, you need to use
return svg.node()
. Again, don’t ask me why.By the way,
d => yScale(d)
is simply short forfunction(d) { return yScale(d) }
. Similarly,(d, i) => xScale(i)
meansfunction(d, i) { return xScale(i)}