carlcraig / tc-angular-chartjs

AngularJS directives for Chart.js
http://carlcraig.github.io/tc-angular-chartjs/
Other
233 stars 83 forks source link

Inexact documentation #74

Closed Zeioth closed 8 years ago

Zeioth commented 8 years ago

When i used the scope of the readme i recieve the error "Cannot read property 'length' of undefined".

$scope.myData = [
  { value : 50, color : "#F7464A" },
  { value : 90, color : "#E2EAE9" },
  { value : 75, color : "#D4CCC5" },
  { value : 30, color : "#949FB1"}
];

I solved it using the right format in the scope:

$scope.myData =  {
    labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
    datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
      backgroundColor: [
        'rgba(255, 99, 132, 0.2)',
        'rgba(54, 162, 235, 0.2)',
        'rgba(255, 206, 86, 0.2)',
        'rgba(75, 192, 192, 0.2)',
        'rgba(153, 102, 255, 0.2)',
        'rgba(255, 159, 64, 0.2)'
      ],
      borderColor: [
        'rgba(255,99,132,1)',
        'rgba(54, 162, 235, 1)',
        'rgba(255, 206, 86, 1)',
        'rgba(75, 192, 192, 1)',
        'rgba(153, 102, 255, 1)',
        'rgba(255, 159, 64, 1)'
      ],
      borderWidth: 1
    }]
  };

Using rc-angular-chartjs 2.0 and charjs 2.1.6

carlcraig commented 8 years ago

Hi, thanks for pointing this out.

It would seem that the data/option structures have changed a great deal in chart.js 2.X ...

I have updated the README with urls for chart.js documention.

I will also be looking to improve the documentation with some better examples.