The "onclick" (or mouseover/mouseout) events are detected and work perfectly fine for a donut chart as seen in this example :
http://c3js.org/samples/chart_donut.html
I tried incorporating the same for a bar chart or a line chart. It doesn't work. Are these events only for donut charts or is there any other possible way I can do it for these charts(Bar, Line and others)?
You can set an onclick in the data section.
Here you will get the event for bar and line chart. You will get the targeted object as argument to your function.
To see what you can get, open console and try
var chart = c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25]
],
onclick: function () {
console.log(arguments);
},
}
});
That works perfect! Thanks :+1:
Thank you! I'll close this.
What about clicking on the line instead of the dot?
Most helpful comment
What about clicking on the line instead of the dot?