Home Forums Chart Support click event for any cursor position

click event for any cursor position

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

    Hello,

    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.

    #5703

    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

    #5705

    Thanks a lot. That what I was looking for.

    #17808

    Is this still a workable solution?

    We need to purchase one license to get the code to do this hack?

    Could I do it in trial version?

    #17820

    @intijk,

    You can use convertPixelToValue method to fetch axis value for any given pixel co-ordinate. You can also get pixel co-ordinate for any axis value using convertValueToPixel.

    —-
    Bivek Singh,
    Team CanvasJS

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

You must be logged in to reply to this topic.