Search code examples
amchartsamcharts4

amCharts 4 - How to Determine if Cursor is Currenlty Showing?


How can you check if the cursor is currently showing (i.e. the mouse cursor is over the chart)?

It was suggested here to use:

if (cursor.hidden || cursor.isHiding) {
  // nope, cursor is not there
}

However, both properties are always false. See this pen.

With the console open, click the "Get Cursor Info In 2 Seconds" button and do not move the mouse (i.e. keep the mouse cursor off the chart so that the cursor is not displayed). Once the setTimeout is complete, both are reported false in the console. At least one should be true.


Solution

  • hidden should be isHidden. So this seems to work:

    if (cursor.isHidden || cursor.isHiding) {
      // nope, cursor is not there
    }