Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create vis service to avoid directly use vis from window object #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions angular-vis.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
angular.module('ngVis', [])

.factory('VisDataSet', function () {
'use strict';

.factory('vis', ['$window', function ($window) {
// Create the global vis object
if (!$window.vis) {
return {};
}
return $window.vis;
}])

.factory('VisDataSet', ['vis', function (vis) {
return function (data, options) {
// Create the new dataSets
return new vis.DataSet(data, options);
};
})
}])

/**
* TimeLine directive
*/
.directive('visTimeline', function () {
.directive('visTimeline', ['vis', function (vis) {
'use strict';
return {
restrict: 'EA',
Expand Down Expand Up @@ -73,12 +80,12 @@ angular.module('ngVis', [])
});
}
};
})
}])

/**
* Directive for network chart.
*/
.directive('visNetwork', function () {
.directive('visNetwork', ['vis', function (vis) {
return {
restrict: 'EA',
transclude: false,
Expand Down Expand Up @@ -159,12 +166,12 @@ angular.module('ngVis', [])
});
}
};
})
}])

/**
* Directive for graph2d.
*/
.directive('visGraph2d', function () {
.directive('visGraph2d', ['vis', function (vis) {
'use strict';
return {
restrict: 'EA',
Expand Down Expand Up @@ -223,5 +230,5 @@ angular.module('ngVis', [])
});
}
};
})
}])
;