Search code examples
javascriptreactjschart.jsreact-chartjs-2

Add space between point of the chart and of the border chart in react-chartjs-2


My chart:

<div style={{height: '100%', marginTop:'-20px'}}>
   <Line data={data} options={options} />
</div>

and options for chart:

const options = {
  scales:{
    yAxes:[{
      scaleLabel:{
        display: true,
      }
    }]
  }
};

enter image description here

Now I have this situation, the second point stops at the upper border. How can I fix this?


Solution

  • You can define ticks.max on the y-axis as follow:

    yAxes:[{
      ticks:{
        min: 0,
        max: 100 // or whatever value that suits you
      }
    }]