Anthony Akpan Anthony Akpan - 25 days ago 9
AngularJS Question

Chart Js + Angular

Am I missing something here? For two days i have looked through this code to see the issue just to get started. I am testing out the Chart Js plugin and I intend to use angular with it.

Seems like there is some sort of conflict with my code that dosent let either of the scripts to run. Please help

//Charts//
// Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext("2d");
var LineChart = new Chart(ctx).Line(data);

//Data//
data = {
labels : ["January", "February", "March", "April", "May", "June", "July"],
datasets : [{
data:[65, 59, 80, 81, 56, 55, 40]
}]
};

var app = angular.module('myApp',[]);
app.controller('MainController', function($scope){
$scope.Title = 'My Charts';
});


http://plnkr.co/edit/RXzjPllg0RSWjvgMjIoU?p=preview

Answer

Got your chart working for you

http://plnkr.co/edit/YrI6RtQTkJkZde3Ynnhq?p=preview

    var app = angular.module('Chart', []);

    app.controller('MainController', ['$scope', function($scope) {

        $scope.greet = 'My Charts';

        data = {
            labels: ["January", "February", "March", "April", "May", "June", "July"],
            datasets: [{
                data: [65, 59, 80, 81, 56, 55, 40]
            }]
        };

        var ctx = document.getElementById("myChart").getContext("2d");
        var LineChart = new Chart(ctx).Line(data);

    }]);

    //Data//