1👍
✅
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>
Source:stackexchange.com