score:1

Accepted answer

you need to add options object and indicate not to display the legend

var options = {
        legend: {
            display: false
        }
    };

then use the options in the constructor of your chart

var mychart = new chart(ctx, {
  type: 'bar',
  responsive: true,
  /* include options in the constructor */
  options: options,
  ... }

see sample below

documentation about options available are on their website: https://www.chartjs.org/docs/latest/getting-started/

var ctx = document.getelementbyid('chart').getcontext("2d");

// add options object - indicate not to display the legend
var options = {
        legend: {
            display: false
        }
    };

var mychart = new chart(ctx, {
  type: 'bar',
  responsive: true,
  /* include options in the constructor */
  options: options,
  data: {
    labels: ["test"],
    datasets: [{
      label: "sfarzoso",
      fill: false,
      bordercolor: '#000',
      borderwidth: 2,
      borderdash: [],
      borderdashoffset: 0.0,
      data: ["1"],
      backgroundcolor: ["#fff5f7"]
    }]
  },
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.7.3/chart.min.js"></script>


<canvas id="chart"></canvas>


Related Query

More Query from same tag