Home forums Using CanvasJS click event for any cursor position

This topic contains 2 replies, has 2 voices, and was last updated by  smbdy 2 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #5702



    Is there any way to handle click event for any mouse position? I found only support for clicks on data points.
    I would like to create mouse click handler for any cursor position and also I want to get the value of X axe corresponding to that position.

    If not supported out of the box, where should I start looking in order to make such extension?

    I’m considering some ugly approach – find the native Canvas element, add mouse handler there, calculate X value for this coordinate (I know max X value and canvas size), but this probably won’t be accurate cause axisY title takes some place on chart … and in general this sounds like a dirty hack.

    What would you recommend? Thank you.


    Sunil Urs

    This will not be possible directly via the existing API. But if you are ok editing CanvasJS code, Axis has a function getXValueAt(x) which can convert given pixel value to X value on axisX. You can make it public by writing few lines of code inside CanvasJS object which is present at the end of file.

    Hope this helps



    Thanks a lot. That what I was looking for.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.