Drawing various shapes with Canvas

Let's add some other basic geometric shapes or graphical primitives to our canvas. As they are the building blocks of all the visuals you draw, some exercise will do us good. Here's what we will draw:

A house and a tree. Or three rectangles under a triangle next to a path and a circle. 
View this step in the browser: https://larsvers.github.io/learning-d3-mapping-8-2. Code example 08_02.html.

You can see the code to the right in the JavaScript console, and before we step through it, let's note some general observations. First, every line starts with context. The Canvas context is really where our drawing ...

Get Learning D3.js 5 Mapping - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.