Estoy usando la agregación promedio en un gráfico combinado. El objetivo es redondear ese resultado a un número entero.
Intenté formatear el número sin decimales después de agrupar. La barra del gráfico resultante no refleja el valor redondeado.
El par de coordenadas (2021/05, 2) es lo que me gustaría que fuera. Explique cómo puedo hacer que el eje Y refleje el número 2, y no el valor no redondeado 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>