Highcharts -鼠标悬停在列上

eni9jsuy  于 9个月前  发布在  Highcharts
关注(0)|答案(1)|浏览(101)

我们正在尝试访问用户悬停的列的值。
最初,我们使用Window.event捕获点,但在升级Angular 和节点版本后,window.event没有按预期响应(因为它已被弃用)。请让我知道任何替代阅读悬停列。
技术栈:Angular 16(从版本8升级)Node 16.16
请帮忙。
我们需要读取柱形图中悬浮柱的值。

plotOptions: {
series: {
    events: {
        mouseOver: ($events) => {
            // I would like to capture data on which mouse is hovering
            console.log($events);
        }
    }
}

}

332nm8kg

332nm8kg1#

首先,你需要用途:

  • plotOptions.series.point.events.mouseOver

而不是:

  • plotOptions.series.events.mouseOver

要获得悬停点,请使用用途:event.target

plotOptions: {
  series: {
    point: {
      events: {
        mouseOver: (event) => {
          console.log(event.target);
        }
      }
    }
  }
}

或基本函数中的this

mouseOver: function (this: Highcharts.Point) {
  console.log(this);
}

现场演示:https://stackblitz.com/edit/highcharts-angular-line-zha7hq?file=src%2Fapp%2Fapp.component.ts
API引用:https://api.highcharts.com/highcharts/plotOptions.column.point.events.mouseOver

相关问题