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 上的悬停模式


- addEventListener 在 IE 11 中不起作用 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06