google.charts.load('current', {
callback: drawChart,
packages:['corechart']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Month', 'Members', {role: 'annotation'}],
['2015-09', 0, '0'],
['2015-10', 0, '0'],
['2015-11', 0, '0'],
['2015-12', 0, '0'],
['2016-01', 1, '1'],
['2016-02', 1, '1'],
['2016-03', 1, '1'],
['2015-04', 3, '3'],
['2016-05', 3, '3'],
['2016-06', 3, '3'],
['2016-07', 3, '3'],
['2016-08', 3, '3'],
['2016-09', 3, '3'],
['2016-10', 4, '4'],
['2016-11', 6, '6'],
['2016-12', 6, '6'],
['2017-01', 8, '8'],
['2017-02', 8, '8'],
['2017-03', 8, '8'],
]);
// remove repeated annotations
var annotationText = null;
for (var i = 0; i < data.getNumberOfRows(); i++) {
if (annotationText === data.getValue(i, 2)) {
data.setValue(i, 2, null);
} else {
annotationText = data.getValue(i, 2);
}
}
var options = {
annotations: {
alwaysOutside: true,
textStyle: {
bold: true,
fontSize: 20
}
},
colors: ['#0097A7'],
hAxis: {
slantedText: true,
textStyle: {
bold: true,
fontSize: 16
}
},
height: 400,
legend: {
position: 'none'
},
vAxis: {
title: data.getColumnLabel(1)
}
};
var container = document.getElementById('chart_div');
var chart = new google.visualization.ColumnChart(container);
chart.draw(data, options);
};
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>