本文介绍了如何使用 d3.js 为圆环图中的数据创建标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个圆环图,可以在点击时更新数据.我想为相同的数据添加标签.我目前正在使用 d3.js javascript 库.这是我在 jsfiddle 上的代码

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?

推荐答案

你必须使用 arc.centroid 函数.看看下面的例子:

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

这篇关于如何使用 d3.js 为圆环图中的数据创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:55
查看更多