Home Forums Chart Support Event handling on data click fails

Event handling on data click fails

Viewing 7 posts - 1 through 7 (of 7 total)
  • #26925

    Hi,

    I’m able to get details from data points via event handling when I have static data. If I use the same way to get details with data called from service(Angular), I’m getting the following error – Error: g[e[f]].call is not a function.

    Here’s the working example I’m using – https://stackblitz.com/edit/test-function-binding

    Thanks,
    Sudha

    #26943

    Sudha,

    The issue seems to be with the binding of click-event handler. onClick that’s being assigned to click event in sample.data.ts file is undefined. Please take a look at this updated sample.

    —-
    Manoj Mohan
    Team CanvasJS

    #26944

    Hi Manoj,

    Thank you so much. It’s working now.

    Also, I have one more doubt. The data that we are fetching in event handling function is not getting reflected in UI though it’s getting updated in console. Is this related to Canvas or some issue with Angular? I have updated the code

    Regards,
    Sudha

    • This reply was modified 4 years, 7 months ago by Sudha. Reason: Updated code link
    #26956

    Sudha,

    The issue seems to be with the context of “this” used in the onClick function. Please take a look at this updated sample.

    —-
    Manoj Mohan
    Team CanvasJS

    #27203

    Hi Manoj,

    This worked. Is there a way to pass the value of i from for loop to onClick function along with e value?

    Thanks,
    Sudha

    #27205

    Please ignore my last message.. I was able to achieve what I wanted, by accessing e.dataPointIndex.

    #27210

    Sudha,

    Glad that you figured it out :)

    —-
    Manoj Mohan
    Team CanvasJS

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

You must be logged in to reply to this topic.