[Chartjs]-Linear x axis for bar chart chartjs

1👍

I don’t recommend to change the axis type to time, as this will introduce several other issues given that there are not "fractional times". And adding support for it is not that easy.

The best bet is to create your own labels with a custom function. For example:

    const f = () => {
      let a = [];
      for (let n = -30; n <= 30; n++) {
        a.push(n / 100 + "");
      }
      return a;
    };

To generate from -3.00 to +3.00 (zeros representing decimal places). The bigger the numbers 30 and 100 the bigger the "resolution" of your linear scale.

Demo: https://codesandbox.io/s/react-chartjs-2-example-forked-26bbx?file=/src/index.js

enter image description here

Leave a comment