我希望将“年龄”一词添加到我的工具提示标题中,以根据图表中的年龄组来表示。
例如,基本上,标题应该是“11-20 岁”。但是,我得到“未定义的年龄”?
有谁知道我为什么会遇到这个问题?
代码(下面的小提琴):
var ageRangedata = {type: 'bar',
data:{datasets: [
{ data : [0,1,5,2,1,0,0, 0, 0, 0], backgroundColor: 'rgba(255, 209, 240, 0.6)', borderColor: 'rgba(255, 209, 240, 1)', borderWidth: 2, label: 'Female' },
{ data : [1,0,1,1,6,1,0, 1, 0, 0], backgroundColor: 'rgba(81, 187, 245, 0.6)', borderColor: 'rgba(81, 187, 245, 1)', borderWidth: 2, label: 'Male' }],
labels:['0-10','11-20','21-30','31-40','41-50','51-60','61-70', '71-80', '81-90', '90-']},
options: {maintainAspectRatio: false,responsive: true, tooltips: { callbacks: { title: function(tooltipItem, data) { return 'Ages ' + data.labels[tooltipItem.Index]; }}},legend: { display: false }}};
var ageR = document.getElementById("ageRange").getContext("2d");
var chart_ageR = new Chart(ageR, ageRangedata);
任何知道使用 afterLabel 将文本发送到标签下方而不是之后的人的额外积分(附带问题,如果您愿意,请忽略)“?