我正在使用charts.js为我的网站创建一个图表。我无法从图表中删除图例。x1c 0d1x
我没有找到解决方案。这是我第一次使用chartsiderjs库。
密码:
const ctx1 = document.getElementById('yearWise').getContext('2d');
const yearWise = new Chart(ctx1, {
type: 'bar',
plugins: [ChartDataLabels],
data: {
legend: 'options',
labels: ['2018-19','2019-20','2020-21','2021-22'],
datasets: [{
data: [90,400,5245,5122],
backgroundColor: [
// 'rgba(255, 99, 132, 0.5)',
'rgba(70, 132, 238, 0.5)',
],
borderColor: [
// 'rgba(255, 99, 132, 1)',
'rgba(70, 132, 238, 1)',
],
borderWidth: 1
}]
},
options: {
legend: {
display: false,
},
responsive: true,
scales: {
y: {
beginAtZero: true,
}
},
plugins: {
title: {
display: true,
text: 'Programs Conducted - Year Wise',
},
datalabels: {
anchor: 'end',
align: 'end',
labels: {
value: {
color: 'rgba(70, 132, 238, 1)'
}
}
},
},
}
});提前感谢。
1条答案
按热度按时间u7up0aaq1#
以下是https://www.chartjs.org/docs/latest/configuration/legend.html文档
只需将
legend.display
设置为false即可。您可以在此处尝试https://codesandbox.io/s/wonj2xn23w?file=/src/index.js