在 Chart.js V3.7.1 中隐藏图例

Hide Legend in Chart.js V3.7.1

我试图隐藏条形图的图例。根据我的理解,这应该有效:

<!DOCTYPE html>
<html>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script>
<body>

<canvas id="myChart" style="width:100%;max-width:600px"></canvas>

<script>
var xValues = ["X", "Y", "Z"];
var yValues = [55, 49, 44];
var barColors = ["red", "green","blue"];

new Chart("myChart", {
  type: "bar",
  data: {
    labels: xValues,
    datasets: [{
      backgroundColor: barColors,
      data: yValues
    }]
  },
  options: {
    plugings: {
        legend: {
            display: false
        },
    },
  },
});
</script>

</body>
</html>

不幸的是,它仍然显示了传说。

您的插件输入有误。将“插件”更改为“插件”

options: {
    plugins: {
        legend: {
            display: false
        },
    },
  }

除此之外应该是正确的