[Chartjs]-Charts.js how to have 2 different size y-axis

1👍

You need to define multiple y-axes as explained in chapter Create Multiple Axis from the Chart.js documentation.

Please take a look at your amended code and see how it works.

var ctx = document.getElementById('skinsChart').getContext('2d');
var skinsChart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ['A', 'B', 'C', 'D'],
    datasets: [{
      label: 'Return Procent',
      data: ["65.7", "63.7", "69.7", "62.7"],
      borderColor: 'rgb(0,0,0)',
      borderWidth: 1,
      backgroundColor: 'rgba(0,0,0,0.2)',
      yAxisID: 'yLeft'
    }, {
      label: 'Price',
      data: ["0.07", "0.08", "0.06", "0.07"],
      borderColor: 'rgb(255,0,0)',
      borderWidth: 1,
      backgroundColor: 'rgba(0,0,0,0.2)',
      yAxisID: 'yRight'
    }]
  },
  options: {
    scales: {
      yAxes: [{
        id: 'yLeft',
      },
      {
        id: 'yRight',
        position: 'right',
      }]
    },
    elements: {
      point: {
        radius: 0
      }
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
<canvas id="skinsChart" height="100"></canvas>

Leave a comment