Home > other >  Remove label from line chart - react-chartjs-2
Remove label from line chart - react-chartjs-2

Time:02-08

I am looking to remove the labels that are in the square in the following picture: https://prnt.sc/26qc8uq. How would I do it? I tried with options: {plugins: {legend: display: false}} but it didn't seem to work. Package I am using is react-chartjs-2

This is the code:

<Chart type="line" data={{
  labels: props.sets[0],
  datasets: props.dataset,
  options: {
   plugins: {
     legend: {
       display: false,
     },           
   }
  }
}} />
    

CodePudding user response:

You are passing the options to the data prop, this is incorrect. You will need to pass the options to the options prop like so:

<Chart type="line"
  options={{
    plugins: {
      legend: {
        display: false,
      },           
    }
  }}
  data={{
    labels: props.sets[0],
    datasets: props.dataset,
  }}
/>
  •  Tags:  
  • Related