From afb2d686f4fd20a89a31eb7aaa44f2234cab4924 Mon Sep 17 00:00:00 2001 From: Qiankun Xie Date: Thu, 16 Mar 2017 15:14:49 -0500 Subject: [PATCH] wip --- angular-vis.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/angular-vis.js b/angular-vis.js index fca672d..624c6f4 100644 --- a/angular-vis.js +++ b/angular-vis.js @@ -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', @@ -73,12 +80,12 @@ angular.module('ngVis', []) }); } }; - }) + }]) /** * Directive for network chart. */ - .directive('visNetwork', function () { + .directive('visNetwork', ['vis', function (vis) { return { restrict: 'EA', transclude: false, @@ -159,12 +166,12 @@ angular.module('ngVis', []) }); } }; - }) + }]) /** * Directive for graph2d. */ - .directive('visGraph2d', function () { + .directive('visGraph2d', ['vis', function (vis) { 'use strict'; return { restrict: 'EA', @@ -223,5 +230,5 @@ angular.module('ngVis', []) }); } }; - }) + }]) ;