Hello, is anyone using Chart.js with ionic and is successfully able to obtain the canvas id to handle onclick?
Graphing works fine, but in the controller, on handleClick the chart object is always returning null
I am using tc-chartjs like so:
In the graph template:
<canvas tc-chartjs-bar chart-data="data" chart-options="options"
ng-click="handleChartClick($event)" chart="chart">
</canvas>
This draws the graph perfectly, but inside handleChartClick, when I try and access $scope.chart I get a undefined object
My handleChartClick code:
$scope.handleChartClick = function (event) {
console.log("HERE" + JSON.stringify(event));
console.log (JSON.stringify( $scope.chart.getBarsAtEvent(event)));
//console.log(angular.element[0].getContext('2d'));
//console.log (JSON.stringify( $scope.chart));
};
This returns an error because $scope.chart is undefined
My includes and usage:
index.html:
// ionic is loaded before this
<script src="lib/Chart.js/Chart.min.js"></script>
<script src="lib/tc-angular-chartjs/dist/tc-angular-chartjs.min.js"></script>
Thanks