Closed blogui91 closed 8 years ago
Same error for me.
Which version are you using? Note that the Chart.js datastructure is changed a bit in version 2.
I installed the package via bower it downloaded the version 2.* by default, I think It should work and I just copy & paste the code, I tried to use other version lower than 2. * version but I still get errors, I will embed them
If you are using version 2, the data structure and options are not correct. See https://github.com/carlcraig/tc-angular-chartjs/blob/master/demo/js/doughnut.js
Ohh so sorry, i just noticed, but i think the documentation in the page should be updated or at least to warn us of using that structure to avoid this kind of issues. Thank you bro!
No problem, I assumed that these pages were already up to date. @carlcraig Could you update these?
This is pretty annoying the code is totally out of date, Also doesn't work with lately angular versions before 2, this should be in DEPRECATED state.
I'm trying to replicate doughnut example, but i am getting this error
angular.min.js:117TypeError: Cannot read property 'length' of undefined at defaults.doughnut.legend.labels.generateLabels (Chart.js:2587) at Chart.Legend.Chart.Element.extend.buildLabels (Chart.js:6123) at Chart.Legend.Chart.Element.extend.update (Chart.js:6071) at getMinimumBoxSize (Chart.js:5773) at Object.helpers.each (Chart.js:4611) at Object.Chart.layoutService.update (Chart.js:5766) at helpers.extend.updateLayout (Chart.js:3859) at initialize (Chart.js:3733) at new Chart.Controller (Chart.js:3714) at new Chart (Chart.js:5587)
As in example i have
<!-- View -->
<section ng-controller="MyController">
<canvas tc-chartjs-doughnut chart-options="options" chart-data="data" auto-legend></canvas>
</section>
` //Controller
app.controller('MyController', ['$scope', function($scope) { // Chart.js Data $scope.data = [{ value: 300, color: '#F7464A', highlight: '#FF5A5E', label: 'Red' }, { value: 50, color: '#46BFBD', highlight: '#5AD3D1', label: 'Green' }, { value: 100, color: '#FDB45C', highlight: '#FFC870', label: 'Yellow' }];
which could be the error??
Thanks in advance! `