Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On click event of a bar chart/line chart #262

Closed
aishwaryak opened this issue May 22, 2014 · 4 comments
Closed

On click event of a bar chart/line chart #262

aishwaryak opened this issue May 22, 2014 · 4 comments

Comments

@aishwaryak
Copy link

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

@DieterSpringer
Copy link

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); 
        },
    }
});

@aishwaryak
Copy link
Author

That works perfect! Thanks 👍

@masayuki0812
Copy link
Member

Thank you! I'll close this.

@mikiasmohamed
Copy link

What about clicking on the line instead of the dot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants