我正在使用图表js绘制折线图。我希望工具提示始终启用。不管我是否将鼠标悬停在图形上,每次都应该看到工具提示,并且在工具提示上我总是希望y轴点的值而不是x轴点的值。可以画这样的东西吗?
var ctx = document.getElementById('myChart').getContext('2d');
ctx.width=500;
Chart.defaults.global.tooltips.enabled = true;
var chart = new Chart(ctx, {
// The type of chart we want to create
type: 'line',
// The data for our dataset
data: {
labels: time,
datasets: [{
borderColor: 'rgb(0, 0, 139)',
data: temperature,
steppedLine: true,
}]
},
// Configuration options go here
options: {
//events: ['click'],
responsive: false,
legend: false,
tooltips: {
mode: 'index',
intersect: false
},
hover: {
mode: 'index',
intersect: false
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Time(Minute)'
}
}],
yAxes: [{
display: true,
ticks: {
labelString: 'Temperature',
beginAtZero: false,
steps: 200,
stepValue: 25,
max: 1200
}
}]
},
},
});
我希望工具提示始终可见,并且工具提示应仅包含y轴值。