Chartjs-How does the chartjs line look start to be greater than 0

0๐Ÿ‘

โœ…

You can add an empty label and to the start of the labels array and a null value to the start of your dataArray to shift it a bit

Example:

var options = {
  type: 'line',
  data: {
    labels: ["", "Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
      label: '# of Votes',
      data: [null, 12, 19, 3, 5, 2, 3],
      borderWidth: 1,
      fill: false,
      borderColor: 'red',
      backgroundColor: 'red'
    }]
  },
  options: {
    scales: {
      yAxes: [{
        ticks: {
          reverse: 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/2.9.4/Chart.js" integrity="sha512-hZf9Qhp3rlDJBvAKvmiG+goaaKRZA6LKUO35oK6EsM0/kjPK32Yw7URqrq3Q+Nvbbt8Usss+IekL7CRn83dYmw==" crossorigin="anonymous"></script>
</body>

0๐Ÿ‘

Is there a way like this?

enter image description here

I wish it would look from that number, not from 0.

Leave a comment