1.

How To Integrate Flot With Angularjs?

Answer»

Since charting involves heavy DOM MANIPULATION, directives are the way to go.

Data can be kept in the Controller

App.controller('Ctrl', function($scope) {
$scope.data = [[[0, 1], [1, 5], [2, 2]]];
});

And you can create a custom HTML tag1 SPECIFYING the model you want to get data from

 <chart ng-model='data'></chart>
which angular can compile through a directive
App.directive('chart', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
var data = scope[attrs.ngModel];
$.plot(elem, data, {});
elem.show();
}
};
});

Since charting involves heavy DOM manipulation, directives are the way to go.

Data can be kept in the Controller

App.controller('Ctrl', function($scope) {
$scope.data = [[[0, 1], [1, 5], [2, 2]]];
});

And you can create a custom HTML tag1 specifying the model you want to get data from

 <chart ng-model='data'></chart>
which angular can compile through a directive
App.directive('chart', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
var data = scope[attrs.ngModel];
$.plot(elem, data, {});
elem.show();
}
};
});



Discussion

No Comment Found