Skip to content

How to get correct x or y-axis label when user click on chart #9463

Discussion options

You must be logged in to vote

I was able to solve it by adding below code:

options: {
  onClick: (event: any, elements: any[], chart: Chart) => {
          var acives = chart.getActiveElements();
          let label :string = <string> chart.data.labels[acives[0].index];
          .....
        },
}

I wish chartjs documentation had a section for Angular specific development needs, would have saved my day.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pavangayakwad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant