我想展示" Not notged"和#34;已确认"在图例中,金额在饼图上显示为标签。我没有看到在指令选项中实现这一目标的方法。
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
}
]
};
答案 0 :(得分:1)
由于图例是根据x
值生成的,因此您可以返回其key
而不是y
。然后将labelType
设置为value
,这将呈现饼的值。
chart: {
type: 'pieChart',
height: 300,
margin: {
top: 0,
right: 20,
bottom: 0,
left: 20
},
color: ["#97bbcd", "#dcdcdc"],
x: function(d){return d.key;},
y: function(d){return d.y;},
labelType: 'value',
legend: {
updateState:false
},
showLabels: true,
showLegend: true,
transitionDuration: 500,
labelThreshold: 0.01
}
答案 1 :(得分:0)
试试这段代码:
$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.key;},
y: function(d){return d.y;},
legend: {
updateState:false
},
showLabels: true,
labelType: 'value',
showLegend: true,
transitionDuration: 500,
labelThreshold: 0.01
}
},
data: [
{
key: 'Not Acknowledged',
y: 18
},
{
key: 'Acknowledged',
y: 44
}
]
};