【发布时间】:2022-12-24 19:50:20
【问题描述】:
我正在尝试在 chartjs v3.3.0 中创建自定义图例模板,如下图所示。我似乎无法在 v3.3.0 中找到有关此选项的任何文档。它甚至可用吗?任何人都可以举例说明如何实现这一目标吗?
这是我的设置:
plugins: {
legend: {
display: true,
onClick: () => {
console.log('do nothing');
},
position: 'bottom',
labels: {
usePointStyle: true,
pointStyle: 'circle',
// generateLabels: (chart) => {
// console.log(chart.legend);
// return [1, 2];
// },
},
},
title: {
text: 'Gender',
display: true,
},
},
},
type: 'doughnut',
data: {
labels: defaultColors,
datasets: [
{
label: 'label1',
data: [1, 2],
backgroundColor: getBackground,
borderWidth: 0,
},
],
},
width: 'auto',
height: '100%',
【问题讨论】:
标签: javascript chart.js