我想在图例中显示“未确认”和“已确认”,并将金额显示为饼图上的标签 . 我没有看到在指令选项中实现这一点的方法 .
http://krispo.github.io/angular-nvd3/#/pieChart
Javascript选项和数据:
$scope.pie = {
options: {
chart: {
type: 'pieChart',
height: 300,
margin: {
top: 0,
right: 20,
bottom: 0,
left: 20
},
color: ["#97bbcd", "#dcdcdc"],
x: function(d){return d.y;},
y: function(d){return d.y;},
legend: {
updateState:false
},
showLabels: true,
showLegend: true,
transitionDuration: 500,
labelThreshold: 0.01
}
},
data: [
{
key: 'Not Acknowledged',
y: 18
},
{
key: 'Acknowledged',
y: 44
}
]
};
2 回答
由于图例是从
x
值生成的,因此您可以返回key
而不是y
. 然后将labelType
设置为value
,这将呈现饼的值 .试试这段代码: