May 2019
Beginner to intermediate
650 pages
14h 50m
English
The d3.arc() function creates an arc generator, which given an inner and outer radius, and a start and end angle, generates an SVG path data string (or Canvas path commands) that draws a circular or annular sector, such as the ones used in pie and doughnut charts. Besides these charts, arcs can also be used to create radial area charts.
The following code creates a generator function for a 90-degree arc starting at 45 degrees (the origin is at 12 o'clock), with an outer radius of 100 pixels and no inner radius (the arc will be drawn as a slice starting at the origin):
const arc = d3.arc() .innerRadius(0) .outerRadius(100) .startAngle(Math.PI * 45/180) .endAngle(Math.PI * 135/180); const slice = arc(); console.log(slice);
The resulting ...
Read now
Unlock full access