Chart js assign default value for y axis

๐Ÿ‘:0

You can use the scaleOverride and scaleLabel options, like so

new Chart(ctx).Line(lineChartData, {
    scaleOverride: true,
    scaleSteps: 2,
    scaleStepWidth: 1,
    scaleStartValue: 0,
    scaleLabel: function(d) {
      switch(d.value) {
        case "0": return 'zero';
        case "1": return 'one';
        case "2": return 'two';
      }
    },
});

Fiddle โ€“ http://jsfiddle.net/zh4c58p6/

Leave a comment