I am having trouble creating a chart with an onClick event that can retrieve the label that was clicked. After searching, I found and modified a solution. Here is my code snippet:
$scope.chart;
$scope.onClick = function (points, evt) {
console.log(points, evt);
if ($scope.chart) {
console.log($scope.chart.getPointsAtEvent(evt));
}
};
On the view side:
<canvas class="chart chart-horizontal-bar"
chart-series="seriesPM"
chart-labels="labelsPM"
chart-data="dataPM"
chart-options="chartOptions"
chart-click="onClick"
id="chart"
></canvas>
However, I am facing an issue where $scope.chart is undefined and I am unsure of how to access this variable.