C3: On click event of a bar chart/line chart

Created on 22 May 2014  路  4Comments  路  Source: c3js/c3

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)?

question resolved maybe

Most helpful comment

What about clicking on the line instead of the dot?

All 4 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patternboxtech picture patternboxtech  路  4Comments

Kreozot picture Kreozot  路  3Comments

udhaya2kmrv picture udhaya2kmrv  路  3Comments

laurentdebricon picture laurentdebricon  路  3Comments

Shugardude picture Shugardude  路  4Comments