c3 icon indicating copy to clipboard operation
c3 copied to clipboard

onclick function in area chart is being fired more than once

Open Sreelakshmigc opened this issue 9 years ago • 5 comments

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 }

areachartonclickissue

Sreelakshmigc avatar Apr 10 '17 12:04 Sreelakshmigc

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.

venkatasandeepd avatar May 02 '17 12:05 venkatasandeepd

Thank you, Sandeep. But the given solution is not working for me. Still waiting for a solution to resolve this issue.

Sreelakshmigc avatar Oct 24 '17 07:10 Sreelakshmigc

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.

venkatasandeepd avatar Oct 25 '17 11:10 venkatasandeepd

My chart has one type and "grouped: false" was not working. what should I do?

guswo5580 avatar Apr 23 '18 12:04 guswo5580

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.

Sreelakshmigc avatar Apr 24 '18 06:04 Sreelakshmigc