972c2cec04
Change-Id: I1de5d55e1ec7c9aeed1cffd4e76f596a78e4e304
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/*global JustGage */
|
|
'use strict';
|
|
|
|
angular.module("ngJustGage", [])
|
|
.directive('justGage', ['$timeout', function ($timeout) {
|
|
return {
|
|
restrict: 'EA',
|
|
scope: {
|
|
id: '@',
|
|
class: '@',
|
|
min: '=',
|
|
max: '=',
|
|
title: '@',
|
|
value: '=',
|
|
options: '='
|
|
},
|
|
template: '<div id="{{id}}-justgage" class="{{class}}"></div>',
|
|
link: function (scope) {
|
|
$timeout(function () {
|
|
var options, key, graph;
|
|
|
|
options = {
|
|
id: scope.id + '-justgage',
|
|
min: scope.min,
|
|
max: scope.max,
|
|
title: scope.title,
|
|
value: scope.value,
|
|
donut: true,
|
|
symbol: '%'
|
|
};
|
|
|
|
if (scope.options) {
|
|
for (key in scope.options) {
|
|
if (scope.options.hasOwnProperty(key)) {
|
|
options[key] = scope.options[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
graph = new JustGage(options);
|
|
|
|
scope.$watch('max', function (updatedMax) {
|
|
if (updatedMax !== undefined) {
|
|
graph.refresh(scope.value, updatedMax);
|
|
}
|
|
}, true);
|
|
|
|
scope.$watch('value', function (updatedValue) {
|
|
if (updatedValue !== undefined) {
|
|
graph.refresh(updatedValue);
|
|
}
|
|
}, true);
|
|
|
|
});
|
|
}
|
|
};
|
|
}]);
|