我在angular-nvd3中有一个饼图。https://krispo.github.io/angular-nvd3/#/pieChart我的问题是有一个饼图,我有5个切片,当所有的饼片都贴上标签时,它看起来非常皱缩在一起。我希望修改图例,以便不只显示密钥,而是显示以下内容:
<key> + <number of records in that key>使用"labelType“我可以更改切片饼图标签上显示的内容,但如何更改图例中显示的内容?
发布于 2016-09-20 13:59:47
在API中找不到执行此操作的任何内容。
但这里有一些通过d3实现的技巧:
渲染后
1)获取所有文本DOM
2)对所有文本运行for循环。
3)获取文本数据并更改内部HTML。
dispatch: {
renderEnd: function(e) {
//for each text
d3.selectAll(".nv-legend text")[0].forEach(function(d){
//get the data
var t= d3.select(d).data()[0];
//set the new data in the innerhtml
d3.select(d).html(t.key + " - " + t.y);
});
}
}工作代码here
https://stackoverflow.com/questions/39580961
复制相似问题