Angle Generator

Learn how to generate angles from data for a pie chart.

We'll cover the following

Introduction

In order to draw arcs, we need the startAngle() and endAngle() as we have discussed in the previous lesson. In real-life data, we don’t have angle information associated with our data. We need some intermediate API between the data and the arc generator to draw pie or donut charts.

D3.js provides an API d3.pie(), which will add angle information to the data.

Let’s see the following code where d3.pie() is used to add angle information based on the value associated with language.

Get hands-on with 1200+ tech skills courses.