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

自古美人都是妖i 提交于 2019-11-29 17:41:27

问题


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?


回答1:


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



回答2:


Please take a look at: http://nvd3.org/examples/pie.html or http://bl.ocks.org/Guerino1/2295263. Check the code and you should be able to answer this question fairly easy. Have fun!



来源:https://stackoverflow.com/questions/12506819/how-to-create-labels-for-data-in-donut-chart-using-d3-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!