Estoy trabajando con chart.js y parece que no puedo cambiar la escala del eje Y para mostrar números enteros, en este ejemplo me gustaría tener solo números redondos en la escala (1,2,3 ,4,5) en lugar del decimal (0 -0,5 - 1,0 - 1,5 - 2,0 - etc)
Estoy usando un gráfico de barras vertical desde aquí: https://www.chartjs.org/docs/latest/samples/bar/vertical.html
y mi configuración actual es esta:
var setVirtualBarChart = function (element, viewModel) { var chArea = element.getContext("2d"); var chartConfig = { type: 'bar', data: { labels: ['Categories'], datasets: [ { minBarLength: 2, label: '0-7 days', barPercentage: 0.75, categoryPercentage: 0.75, data: viewModel.ZeroToSevenDaysUser(), backgroundColor: window.chartColors.BrightVisibleGreen }, { minBarLength: 2, label: '8-30 days', barPercentage: 0.75, categoryPercentage: 0.75, data: viewModel.SevenToThirtyDaysUser(), backgroundColor: window.chartColors.Orange }, { minBarLength: 2, label: '30+ test days', barPercentage: 0.75, categoryPercentage: 0.75, data: viewModel.ThirtyPlusDaysUser(), backgroundColor: window.chartColors.BrightRed } ] }, options: { responsive: true, maintainAspectRatio: false, scales: { xAxes: [ { stacked: false, display: true, scaleLabel: { display: true, //labelString: 'Categories', gridLines: { offsetGridLines: true } } } ], yAxes: [ { stacked: false, display: true, scaleLabel: { display: true, labelString: 'Number of invoices' }, ticks: { precision: 0, min: 0 } } ] } } }; VirtualBarChart = new Chart(chArea, chartConfig); };Está utilizando la sintaxis v2 mientras usa v3, en v3 todas las escalas son objetos y ya no son matrices. Para todos los cambios, lea la guía de migración
Ejemplo:
const options = { type: 'bar', data: { labels: ["Red", "Blue", "Yellow"], datasets: [{ label: '# of Votes', data: [1, 2.5, 1.5], backgroundColor: ["Red", "Blue", "Yellow"] }] }, options: { scales: { y: { ticks: { stepSize: 1 }, } } } } const ctx = document.getElementById('chartJSContainer').getContext('2d'); new Chart(ctx, options); <body> <canvas id="chartJSContainer" width="600" height="400"></canvas> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script> </body>