Chartjs-Tooltip is not displayed when using annotation in ChartJs

0👍

I solved this problem by move chart update into the condition

export const handleHoverChart = (myChart, x, scaleID) => {
       const indexLine = myChart.options.annotation.annotations.findIndex(i => i.key === "hoverLine")
       if(indexLine === -1){   
           myChart.options.annotation.annotations.push(convertToHoverLine(x,scaleID))
           myChart.update()
        }else{
              myChart.options.annotation.annotations[indexLine] = convertToHoverLine(x,scaleID);
             }
 }

Leave a comment