score:1

Accepted answer

you have to use the axis callbacks (docs), especially afterbuildticks.

in my linked example (jsbin) i push 0 to my data because you can't use beginatzero: true and remove all the duplicates in the array.

data.push(0); //if 'beginatzero' is wanted
let uniquedata = data.filter((v, i, a) => a.indexof(v) === i);

in the options you define the min and max values and the ticks in afterbuildticks.

options: {
  scales: {
    yaxes: [{
      ticks: {
        autoskip: false,
        min: math.min(...uniquedata),
        max: math.max(...uniquedata)
      },
      afterbuildticks: function(scale) {
        scale.ticks = uniquedata;
      }
    }]
  }
}

you will have problems with overlapping ticks but i don't know a general way to prevent that and i don't know your specific use case.


Related Query

More Query from same tag