I am using Google Chart's column graph chart. The chart is a stacked column chart with annotations for every data point of the stacked column. The annotation are at the top of the inside of the bar but I would like them to be centred inside of the bar. The closest solution I found was moving the annotation of a non stacked column google chart to the bottom here.
The problem with this solution is that the code looks for annotation that are white and moves them to the bottom. The graph I am working on has multiple colours for the annotations and all the annotation of that colour move to the top vs the centre of the subset of the stacked column.
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Range', 'score range A',{role: 'style'},{ role: 'annotation' }, 'score range B',{role: 'style'},{ role: 'annotation' }, 'score range C', {role: 'style'},{ role: 'annotation' },'score range D', {role: 'style'},{ role: 'annotation' }],
['Range', 4,'#D7F0B4','0-4',6,'#00B050','5-10',9,'#92D050','11-19',6, '#AAE182','20-25']
]);
var options = {
vAxis:{ ticks: [0,4,10,19], viewWindow: { max: 25} },
isStacked: true,
title: 'Score',
legend: {position: 'none'}
};
var chart = new google.visualization.ColumnChart(document.getElementById('idealchartA'));
chart.draw(data, options);
}
@Whitehat solved the above problem but when I another column with some of the annotation values as null the positioning gets thrown off.
here is the new data series I tried to add
['Range', 4,'#D7F0B4','0-4',6,'#00B050','5-10',9,'#92D050','11-19',6, '#AAE182','20-25'], ['Yours', 4,'white; fill-opacity: 0',null,6, '#00B050',10, 9,'white; fill-opacity: 0',null,6,'white; fill-opacity: 0',null]
.
The idea is to have a graph like the attached image below but with the annotations centred.
See Question&Answers more detail:
os