I'm using the average aggregation in a combo chart. The goal is to round that result to an integer.
I've tried formatted the number to no decimal after grouping. The resulting chart bar does not reflect the rounded value.
The coordinate pair (2021/05, 2) is what I would like it to be. Please explain how I can get the Yaxis to reflect the number 2, and not the un-rounded value 1.xx ?
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable([
['Month', 'Value'],
['2021/05', 1.1],
['2021/05', 2.1],
['2021/06', 3.1],
['2021/06', 4.1],
['2021/07', 5.1],
['2021/07', 6.1]
]);
let group = google.visualization.data.group(data, [0], [{'column': 1, 'aggregation': google.visualization.data.avg, 'type': 'number'}]);
var formatter = new google.visualization.NumberFormat(
{pattern:"###,###"});
formatter.format(group, 1); // Apply formatter to second column
var options = {
title: 'TITLE',
vAxis: {
title: 'AVERAGE'
},
hAxis: {
title: 'MONTH'
},
seriesType: 'bars',
series: { },
isStacked: true
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(group, options);
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>