Chart.js 上的悬停模式
当您没有悬停在折线图中的特定点"上时,是否可以激活悬停?
Is it possible to have the hover activated when you are not hovering over a specific 'point' in a line graph?
当我将鼠标悬停在图表的任何部分上时,我希望 那个 特定的工具提示能够激活.
I want that particular tooltip to activate whenever I hover over any part of the chart.
类似 http://watchstocks.herokuapp.com/
推荐答案
是的,您可以使用 chart.js 配置工具提示,以获得与您引用的图表类似的行为.
Yes, you can use chart.js to configure tooltips to get a similiar behavior to the chart that you referenced.
有关详细信息,请查看 模式
工具提示配置选项和 hover 配置选项满足您的需求.这是一个例子.
For more information, check out the mode
tooltip config option and hover config options for your needs. Here is an example.
options: {
responsive: true,
title:{
display:true,
text:'Chart.js Line Chart'
},
tooltips: {
mode: 'index',
intersect: false,
},
hover: {
mode: 'nearest',
intersect: true
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
},
}]
}
}
这是一个 codepen 示例,展示了与您的示例相匹配的行为.
Here is a codepen example demonstrating the behavior that matches your example.
相关文章