liveBook · Manning

Angle

As explained in D3.js in Action, Third Edition

An angle is the measure of rotation from a reference direction to a point or geometric ray.

An angle measures rotation from a reference direction to a geometric ray or point. In a polar coordinate system, it works with a radius to describe position around an origin. section 4.4.1

Use angles to position and construct arcs in SVG visualizations:

  • Measure the angle clockwise from the 12 o’clock reference direction. section 4.4.1
  • Convert a percentage into degrees by multiplying it by 360. section 4.4.1
  • Convert degrees to radians by multiplying by π and dividing by 180, because D3’s arc generator expects radians. section 4.4.1 section 4.5
  • Provide starting and ending angles to d3.arc(), alongside inner and outer radii, to define an arc. section 4.5

Mapping precipitation days to an arc

If 126 of 365 days contain precipitation, the percentage is about 35%. Convert that percentage to 126 degrees, then convert 126 degrees to radians before passing the value to an arc generator. section 4.4.1

Figure 4.24 The dimensions of a Cartesian coordinate system are perpendicular to one another, while the polar coordinate system uses the radius and angle dimensions to describe a position in space.
figure

Compare Cartesian coordinates, which use perpendicular x and y dimensions, with polar coordinates, which use radius and angle. section 4.4.1

How D3.js in Action, Third Edition covers it

How deep it goes
Explains polar positioning, percentage-to-angle calculations, degree-to-radian conversion, and D3 arc accessors.
Examples
Uses a precipitation chart that maps 35 percent of 2021 days to a 126-degree arc.
What you can do after
Apply angles via D3’s arc generator to construct SVG arcs from percentages and radii.
How it connects
Connects angles with polar coordinates, Cartesian coordinates, SVG arcs, radians, and D3’s arc generator.

Also explained in

Compare how 2 books explain angle →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.