Google堆积柱形图:每个组的显示值

Nic*_*las 2 javascript google-visualization

使用Google 堆叠的柱状图/条形图,可以这样显示每个组上的值:在此处输入图片说明

我尝试使用批注,但是如果我没记错的话,它只允许我们批注整个列,例如在此代码中打开http://codepen.io/anon/pen/xLIuB

...
var data = google.visualization.arrayToDataTable([
    ['API Category', 'Social', 'Music', 'File Sharing', 'Storage',
     'Weather', { role: 'annotation' } ],
    ['2011', 98, 53, 12, 16, 6, '15'],
    ['2012', 151, 34, 26, 36, 49, '14'],
    ['2013', 69, 27, 22, 17, 15, '14'],
]);
...
Run Code Online (Sandbox Code Playgroud)

小智 6

您可以在类别之间添加更多“ {角色:'注释'}”类型:

var data = google.visualization.arrayToDataTable([
    ['API Category', 
        'Social', { role: 'annotation' }, 
        'Music', { role: 'annotation' }, 
        'File Sharing', { role: 'annotation' }, 
        'Storage', { role: 'annotation' },
        'Weather', { role: 'annotation' } 
    ],
    ['2011', 98, '98', 53, '53', 12, '12', 16, '16', 6, '6'],
    ['2012', 151, '151', 34, '34', 26, '26', 36, '36', 49, '49'],
    ['2013', 69, '69', 27, '27', 22, '22', 17, '17', 15, '15'],
]);
Run Code Online (Sandbox Code Playgroud)

资料来源:Google图表堆积的列,每一列的注释都不同