Ng2-charts: Click event behavior

Created on 29 Jun 2017  路  3Comments  路  Source: valor-software/ng2-charts

Using ng2-charts, I have created a bar chart. Using chartClick event, I am not able to differentiate on which bar the click event is happening. Could you please let me know if there is any way to differentiate it?

Most helpful comment

Below is one way to solve this issue:
public chartClicked(e: any): void {
if (e.active.length > 0) {
var chartElement = e.active[0]._chart.getElementAtEvent(event);
console.log(chartElement[0]._model.datasetLabel)
}
}

All 3 comments

Below is one way to solve this issue:
public chartClicked(e: any): void {
if (e.active.length > 0) {
var chartElement = e.active[0]._chart.getElementAtEvent(event);
console.log(chartElement[0]._model.datasetLabel)
}
}

Hi,
I am new in Angular so please don't mind me asking basic questions.
My query- I have a bar graph and my project requirement is to display all the bar details with some additional info in a TABLE when clicked on bars of graph.
Please help as to how i can implement this or share me some useful links.
Thanks in advance.

chartElement[0]._model.datasetLabel it's for lable. what I need use to print bar chart clicked value. Could you please let me know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteeledSlagle13 picture SteeledSlagle13  路  3Comments

sarn3792 picture sarn3792  路  4Comments

tushartgsit picture tushartgsit  路  5Comments

shyamal890 picture shyamal890  路  4Comments

alexcastillo picture alexcastillo  路  5Comments