Chartjs-How to change the Y-axis value in chartjs

1πŸ‘

Is this what you are looking for?

var data = {
    labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "#FFC069",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#FF9C85",
            data: [45, 39, 40, 31, 26, 45, 10, 36, 25, 30, 2, 10]
        }
    ]
};

var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Line(data, {
    // adjusting your scale labels
    scaleLabel: "<%=value/10%>M",
    // adjusting your scale
    scaleOverride: true,
    scaleSteps: 5,
    scaleStepWidth: 10,
    scaleStartValue: 0,
    // ajusting tooltips
    tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value / 10 %>M",
});

Fiddle – http://jsfiddle.net/t0o07xbf/

0πŸ‘

you can add this properties into your code:

scaleOverride : true,
scaleSteps : 5,
scaleStepWidth : 5,
scaleStartValue : 0, 

Leave a comment