[英]How do you hide the title of a chart tooltip?
I'm using chart js to show grouped bar chart and try to hide the title of the tooltip 我正在使用图表j来显示分组条形图并尝试隐藏工具提示的标题
Code to generate bar 代码生成栏
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
labels: ["Chocolate", "Vanilla", "Strawberry"],
datasets: [
{
label: "Blue",
backgroundColor: "blue",
data: [3,7,4]
},
{
label: "Red",
backgroundColor: "red",
data: [4,3,5]
},
{
label: "Green",
backgroundColor: "green",
data: [7,2,6]
}
]
};
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
barValueSpacing: 20,
scales: {
yAxes: [{
ticks: {
min: 0,
}
}]
}
}
});
In the tooltip it showing the labels Chocolate,Vanilla,Strawberry and i have tried to hide the label with following 在工具提示中显示标签巧克力,香草,草莓和我试图隐藏标签与以下
by setting the titlefontsize to 0 but it doesnt work 通过将titlefontsize设置为0但它不起作用
tooltipTitleFontSize: 0
and i have tried with the tooltip callbacks it disables the label blue,red,green but i wont need that 我已尝试使用工具提示回调它禁用标签蓝色,红色,绿色,但我不需要
tooltips: {
callbacks: {
label: function(tooltipItem) {
return tooltipItem.yLabel;
}
}
}
Help me thanks in advance 提前谢谢你
To hide the title of tooltip, you need to return an empty function on tooltips title 's callback, like so ... 要隐藏工具提示的标题,你需要在工具提示标题的回调返回一个空的功能,这样的...
options: {
tooltips: {
callbacks: {
title: function() {}
}
},
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.