Chart.js 上的悬停模式 [英] hover mode on Chart.js

查看:18
本文介绍了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 上的悬停模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆