Chartjs-(Chart.js) Is there a way to compare one chart with another so as not to have this inconsistent effect of small values being as big as big values?

1πŸ‘

βœ…

To achieve this you will need to know the max value of your first chart. If you know this you can set the the suggestedMax value in the ticks options for the yAxes to that value.

var options = {
  type: 'bar',
  data: {
    labels: ["Red"],
    datasets: [{
      label: '# of Votes',
      data: [2],
      borderWidth: 1,
    }]
  },
  options: {
    scales: {
      yAxes: [{
        ticks: {
          suggestedMax: 25
        }
      }]
    }
  }
}

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>

Leave a comment