GraFiddle / angular-chart

AngularJS directive for adjustable dynamically updating c3 charts
http://grafiddle.github.io/angular-chart/
MIT License
127 stars 40 forks source link

Get data on click #113

Closed speed-e closed 8 years ago

speed-e commented 8 years ago

Hi, I was looking through your documentation and I can't seem to find how would one handle clicking on a chart? When I click one of the series on the pie chart I would like to drill down deeper into the dataset (loaded dynamically as JSON). How would you catch the part of data that has been selected? I tried using options.state.selected, but that did not work. Any help would be greatly appreciated :)

Thanks!

btm1 commented 8 years ago

@speed-e you can accomplish this by adding the click event to the "chart" portion of the config object:

            $scope.mychartconfig = {
                 dimensions: {},
                chart: {
                    data: {
                        onclick: function(d, elem) {
                        //do some stuff
                        }
                    }
                }   
            }
maxklenk commented 8 years ago

@speed-e the posted solution is what you need. Please tell us if you need more support.