Chartjs-How can I automatically rescale the y axis of my log chart using ChartJS?

0👍

I’m not sure what your data looks like, but I’m assuming it’s an array of values with numbers, all you’d need to do is find the max number than add a little buffer on the end to keep the graph looking pretty, so the max number it goes to, then add a little on the end.

function getMax(arr) {
  const max = Math.max(...arr).toString();
  const newMax = 1 + "0".repeat(max.length);
  return newMax
}
max: getMax(values)

Leave a comment