0
在下面的代碼中,我需要的工具提示是這樣的概率:40觀衆:5000即在工具提示中我需要xAxes標籤字符串與xAxes值和yAxes標籤字符串與yAxes value.How實現這個請幫助在chart.js中的自定義工具提示
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Audience',
data: [{x:12,y:9000}, {x:30, y:6000}, {x:40, y:5000},{x:52,y:4000},{x:70,y:3000},{x:92,y:2000}],
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 159, 64, 1)',
borderWidth: 1
}]
},
options: {
tooltips:
{
callbacks:
{
label: function(tooltipItem, data) {return data.datasets[tooltipItem.datasetIndex].label+':'+ tooltipItem.yLabel;
}
}
},
scales: {
xAxes: [{
type: 'linear',position: 'bottom',
scaleLabel:{labelString:"Probability",display:true},
ticks: {
beginAtZero:true,
max:100
}
}],
yAxes: [{
scaleLabel:{labelString:"Audience",display:true},
ticks: {
min: 1000
}
}]
}
}
});