hover mode on Chart.js(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.
这篇关于Chart.js 上的悬停模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chart.js 上的悬停模式


基础教程推荐
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 直接将值设置为滑块 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01