Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create labels for data in donut chart using d3.js

I have a donut chart which updates data on click. I want to add labels to the same data. I am currently using the d3.js javascript library. Here is my code on jsfiddle

What I don't understand it how to add labels to segments of the donut chart?

like image 910
Swaraj Avatar asked Sep 20 '12 05:09

Swaraj


People also ask

How do you add labels in donut chart?

To add text labels with arrows that point to the doughnut rings, do the following: On the Layout tab, in the Insert group, click Text Box. Click on the chart where you want to place the text box, type the text that you want, and then press ENTER.

How do you make a 3D donut chart?

To build a 3D Doughnut chart, use the anychart. pie3d() chart constructor and the innerRadius() method to set the inner radius. The radius is 0 by default and can be set either as a value or a percentage of the chart's bounds.


1 Answers

You have to use the arc.centroid function. Take a look at the following examples:

  • http://jsfiddle.net/nrabinowitz/GQDUS/
  • http://bl.ocks.org/2295263
  • http://jsfiddle.net/MX7JC/9/
  • http://blog.stephenboak.com/2011/08/07/easy-as-a-pie.html
like image 184
zemirco Avatar answered Sep 20 '22 19:09

zemirco