首页 > 解决方案 > 为了显示工具提示,有没有办法增加特定点的灵敏度?

问题描述

我有一个包含多个点的 Highcharts 面积图。这些点的一部分是特殊的,因此用符号(图像)表示。
当有其他点非常靠近特殊点时,很难显示特殊点的工具提示。相反,它显示另一点的工具提示,即使鼠标指针正好在特殊点上。
是否有可能使特殊点对鼠标指针更敏感,以便当我将鼠标移到它的符号(图像)上时它的工具提示将被克服。

这是我的意思的一个例子(jsfiddle) - jsfiddle.net/orenise/cgz7t3yq/30 当我越过太阳标记时,我希望专注于它,它现在的工作方式是如果我有其他观点靠近它,他们可能会成为焦点

标签: highcharts

解决方案


您可以使用 tooltip.formatter 回调禁用这些点的悬停状态并关闭它们的工具提示。

禁用悬停:

  {
    x: 1584339600,
    y: 24,
    id: 'noTooltip',
    marker: {
      states: {
        hover: {
          enabled: false
        }
      }
    },
  },

工具提示自定义:

  tooltip: {
    formatter() {
      var output = `<span style="font-size: 10px">${Highcharts.time.dateFormat('%A, %b %e, %H:%M:%S', this.key)
     }</span><br>
     <span style="color:${this.point.color}">●&lt;/span> ${this.point.series.name}: <b>${this.point.y}</b><br/>`
      if (this.point.id === 'noTooltip') {
        return false
      } else {
        return output
      }
    }
  },

演示:https ://jsfiddle.net/BlackLabel/zbcvLjx3/

API:https ://api.highcharts.com/highcharts/tooltip.formatter

API:https ://api.highcharts.com/highcharts/series.line.marker.states.hover.enabled


推荐阅读