Is it any way to hide some labels from the legend in chart js
?
有没有办法隐藏一些标签在图表js中?
I know, that I can hide all legend, using this option: legend: { display: false }
but I need to hide just a part of labels in the legend.
我知道,我可以使用这个选项:legend: {display: false}隐藏所有的legend,但是我需要在legend中只隐藏标签的一部分。
1 个解决方案
#1
2
I've found an answer. It is possible to generate new labels, using generateLabels
function such like this:
我发现答案。使用generateLabels函数可以生成新的标签,如下所示:
legend: {
labels: {
generateLabels: function(chart) {
return [
{
text: 'text',
fillStyle: 'red'
}
]
}
}
}
#1
2
I've found an answer. It is possible to generate new labels, using generateLabels
function such like this:
我发现答案。使用generateLabels函数可以生成新的标签,如下所示:
legend: {
labels: {
generateLabels: function(chart) {
return [
{
text: 'text',
fillStyle: 'red'
}
]
}
}
}