3๐
โ
You can do this,
<canvas id="pie" chart-click="onClick" class="chart chart-pie"chart-data="data" chart-labels="labels"></canvas>
Controller:
app.controller('AppCtrl', ['$scope', function($scope){
$scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"];
$scope.data = [300, 500, 100];
$scope.onClick = function (points, evt) {
console.log(points, evt);
};
}]);
2๐
A solution that worked for me to get the data when you click on a bar is the following
$scope.clickBar = (points, evt, element) => {
if (element != undefined) {
console.log(points,evt,element);
}
};
1๐
If you still need help with that, for the recent version, you get the label with:
$scope.onClick = function (points, evt) {
console.log(points[0]._view.label);
}
Source:stackexchange.com