我想为图表的工具提示分配不同的标题(使用图表js 2.9.2创建),因此我创建了一个数组,该数组应始终相应显示。不幸的是,它没有按我希望的那样工作。我希望有人可以帮助我解决这个问题。
我的数组如下:
var new_title = [<?php echo "'".$title_new."'";?>];
我的尝试如下:
title: function(tooltipItem, data) {
for (var x = 0; x < tooltipItems.length; x++) {
return new_title[x];
};
},
在此先感谢我的英语不好。
答案 0 :(得分:0)
您可以尝试更新public class UserParams
{
private const int MaxPageSize = 50;
public int PageNumber { get; set; } = 1;
private int pageSize = 10;
public int PageSize
{
get { return pageSize; }
set { pageSize = (value > MaxPageSize) ? MaxPageSize : value; }
}
}
回调,例如:
title
演示:
title: function(tooltipItem, data) {
return new_title[tooltipItem[0].index];
},
const new_title = ['This is a custom title'];
new Chart($("#barchart"), {
type: 'horizontalBar',
data: {
"labels": ["Label"],
"datasets": [{"data": [40]}]
},
options: {
tooltips: {
callbacks: {
title: function(tooltipItem, data) {
return new_title[tooltipItem[0]['index']];
}
}
}
}
});