onclick function in area chart is being fired more than once
I am using c3 onclick function to show the details of the chart data. This works fine in pie/donut charts and even bar charts. But while using area chart, the event is being fired again and again on selecting an area having multiple points. Please help me with a solution for this.
the function call I am using is as below onclick: function(d,i) { //my function }

you may have data.selection.grouped = true, if you change that option to false, onclick will fire only when you click on particular datapoint but if you have used true, wherever you click on that particular datapoint line, the event will be triggered.
Thank you, Sandeep. But the given solution is not working for me. Still waiting for a solution to resolve this issue.
Here is the fiddle Please click on particular data point to trigger onclick event. If you change grouped key to true, you will have multiple triggers, depends of number of data points.
My chart has one type and "grouped: false" was not working. what should I do?
Hi I found a better solution to this problem.
-
This happens only if you have overlapping values in the charts.
-
It is called with respect to the overlapping numbers like if I have 3 vaues falling under count of 5 on the same date in the above graph the click will be called for each of them making it 3 clicks.
-
I resolved this by having multiple tabs dialog / modal on click of the chart.
-
All 3 values will be shown a seperate tab inside my modal.
Code bit looks something like below:
onclick: function (d, i) {
clickCount++;
var axis_x_Value = this.internal.config.axis_x_categories[d.x];
var axis_x_label = this.internal.config.axis_x_label;
showPivotTableForCharts(input, d, axis_x_label, axis_x_Value);
}
Hope this helps. Thanks closing this issue.