score:0

Accepted answer

you can make the scale a linear scale and just provide the x and y as coordinates.

var options = {
  type: 'bar',
  data: {
    datasets: [{
      label: 'nice label',
      data: [{
        x: 10,
        y: 5
      }, {
        x: 13,
        y: 3
      }, {
        x: 20,
        y: 8
      }, {
        x: 22,
        y: 15
      }],
      backgroundcolor: 'pink'
    }]
  },
  options: {
    scales: {
      x: {
        type: 'linear',
        ticks: {
          maxtickslimit: 4
        },
        grid: {
          display: false
        }
      },
      y: {
        grid: {
          display: false
        }
      }
    }
  }
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.6.0/chart.js"></script>
</body>


Related Query

More Query from same tag