liveBook · Manning

startAngle()

As explained in D3.js in Action, Third Edition

startAngle() is an arc-generator method that sets or accesses the starting angle of an arc.

startAngle() is a D3 arc-generator accessor for setting or accessing the angle where an arc begins. Angles supplied to the generator must be expressed in radians. section 4.5

Use startAngle() alongside related arc-generator accessors:

  • Pair it with endAngle() to define an arc's angular span. section 4.5
  • Combine it with innerRadius(), outerRadius(), padAngle(), and cornerRadius() to shape the arc. section 4.5
  • Pass a data accessor such as d => d.startAngle when each annotated datum supplies its own starting angle. section 5.1.3

Generating arcs from annotated data

const arcGenerator = d3.arc() .startAngle(d => d.startAngle) .endAngle(d => d.endAngle) .innerRadius(60) .outerRadius(100) .padAngle(0.02) .cornerRadius(3); Each generated path uses this function to calculate its SVG d attribute, producing the corresponding donut slice. section 5.1.3

const centroid = arcGenerator
  .startAngle(0)
  .endAngle(angleDaysWithPrecipitation_rad)
  .centroid();

Inspect a concrete chain that fixes an arc's starting angle at zero before calculating its centroid. section 4.4.3

How D3.js in Action, Third Edition covers it

How deep it goes
Explains accessor configuration, datum-driven angles, radians, and path generation, while deferring deeper arc mathematics.
Examples
Demonstrates fixed and datum-driven start angles in precipitation-arc labels and multiple-year donut charts.
What it assumes
Assumes familiarity with d3.arc(), SVG paths, and bound data while establishing radians and related arc accessors.
What you can do after
Apply it via D3 to generate correctly positioned arcs from fixed angles or annotated dataset values.
How it connects
Connects startAngle() with arc generators, endAngle(), radii, padding, corner rounding, centroids, and data binding.

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.