How to change chart.js display c,

0

I'm learning to work chartsjs I bring date, with January value with 10 clients, the scale is 0.5, 1.0,1.5,2.0 I would like to deichar with 1,2,3,4, ... there is no half client

/*********************************** GRÁFICO DE LINHAS DIARIO ***********************************/
function os_dia() {
var periodoDia = $('#os_select').val();
$.ajax({
    type: 'POST',
    dataType: 'json',
    data: {
        periodoDia: periodoDia
    },
    url: BASE_URL + 'home/lista_homeDia',
    success: function(resposta) {
        console.log(resposta);
        data = {
            labels: Object.keys(resposta),
            datasets: [{
                label: 'OS por Dia',
                data: ret(resposta),
                borderWidth: 2,
                borderColor: '#80B6ED',
                backgroundColor: '#80B6ED',
                fill: false
            }]
        };
        options = {
            labels: {
                fontStyle: 'bold'
            }
        };
        Chart.defaults.global.responsive = true;
        var contexto = document.getElementById("graficoOsDia").getContext("2d");
        grafico = new Chart(contexto, {
            type: 'line',
            data: data,
            options: options
        });
    }
});
        }
     function ret(param) {
          var valores = [];
      $.each(param, function(key, val) {
    valores.push(val);
     });
     return valores;
      }



                os_dia();

             $("#os_select").change(function() {
           os_dia();
            });
    
asked by anonymous 07.12.2017 / 09:50

1 answer

2

You can add one to both the X-axis and Y-axis scales

scales: {
    yAxes: [{
        ticks: {
            max: 5,
            min: 0,
            stepSize: 1
        }
    }]
}

In the max option, you choose the maximum scale value, the min the minimum value, the stepSize is how much your scale will increase, if any: 1.

EDIT : You do not need to pass the value min and max if you do not want it, it's just for information.

You can find more information here link

I hope I have helped!

    
07.12.2017 / 11:25