NVD3/AngularJS で多棒グラフを作成しました。以下の JSON に示すように、各長方形のバー内にテキストとその値を表示したいと考えています。
各バー内のグラフにテキスト値を表示するにはどうすればよいですか?
NVD3 チャートの定義
multiBarChart: {
options: function(){
return {
chart: {
type: 'multiBarChart',
stacked: true,
x: function(d){return d.x;},
y: function(d){return d.y;},
text: function(d){return d.x;},
showLabels: true,
showLegend: false,
transitionDuration: 500,
forceX: ["Team", "Meeting", "Phase", "Source"],
xAxis: {
axisLabel: 'Category',
axisLabelDistance: -8
},
yAxis: {
axisLabel: 'Number Of Action Items',
}
}
}
},
data: categoryChartData
}
JSON データ (categoryChartData)
[
{"values" : [
{
"y" :10,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Team1"
},
{"values" : [
{
"y" :5,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Team2"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 7,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Meeting1"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 3,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Meeting2"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :9,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Phase1"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :5,
"x" : "Phase"
}, {
"y" : 0,
"x" : "Source"
}
],
"key" : "Phase1"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 2,
"x" : "Source"
}
],
"key" : "Internal"
},
{"values" : [
{
"y" :0,
"x" : "Team"
}, {
"y" : 0,
"x" : "Meeting"
},
{
"y" :0,
"x" : "Phase"
}, {
"y" : 1,
"x" : "Source"
}
],
"key" : "Customer"
}
];