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, now let and const 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 for function(d) { return yScale(d) }. Similarly, (d, i) => xScale(i) means function(d, i) { return xScale(i)}