首页 > 解决方案 > 调用 MouseLeave chartJs Angular

问题描述

我有以下代码:

角组件html

<canvas myChart>
   [dataset] = "dataVariable"
   [labels] = "labelVariable"
   (chartHover) = "chartHover($event)"
</canvas>

组件.ts

public chartHover(e: any){
   //Perform operations
}

每当我将鼠标悬停在一个元素上时,我实际上是在调用一个自定义弹出窗口。问题是我还没有找到触发mouseleave事件使组件消失的方法。

我试过这个:

(chartMouseLeave) = "funct()"

这样做的正确方法是什么?

标签: javascriptangularchart.jsfrontend

解决方案


您可以将事件绑定到mouseout画布的事件。

<canvas myChart>
   [dataset] = "dataVariable"
   [labels] = "labelVariable"
   (chartHover) = "chartHover($event)"
   (mouseout) = "mouseOut($event)"
</canvas>

零件

public mouseOut(event: any){
   // set pop up open flag to false
}

推荐阅读