score:1

Accepted answer

if you make sure your last points fall outside of the chartarea so the line contiues to keep going it will fill correclty:

const options = {
  type: 'line',
  data: {
    datasets: [{
      label: '# of votes',
      data: [{
        x: 0,
        y: 20
      }, {
        x: 30,
        y: 0
      }],
    }, {
      label: '# of points',
      fill: '-1',
      data: [{
        x: 0,
        y: 15
      }, {
        x: 25,
        y: 0
      }],
    }]
  },
  options: {
    scales: {
      x: {
        type: 'linear',
        min: 10,
        max: 20
      },
      y: {
        min: 0,
        max: 20
      }
    }
  }
}

const ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.7.0/chart.js"></script>

<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
</body>


Related Query

More Query from same tag