From d2989efbaf1a881a31b9fd6464a0a46eecde38fd Mon Sep 17 00:00:00 2001 From: Roger Abelenda Date: Fri, 1 May 2015 21:34:22 -0300 Subject: [PATCH] Add component attribute to be able to easily interact with the visualization component. For example with this new attribute is possible to do something like: $scope.component.selectNodes("1"); --- angular-vis.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/angular-vis.js b/angular-vis.js index 041aa89..4c503f0 100644 --- a/angular-vis.js +++ b/angular-vis.js @@ -19,7 +19,8 @@ angular.module('ngVis', []) scope: { data: '=', options: '=', - events: '=' + events: '=', + component: '=' }, link: function (scope, element, attr) { var timelineEvents = [ @@ -46,6 +47,7 @@ angular.module('ngVis', []) // Create the timeline object timeline = new vis.Timeline(element[0]); + scope.component = timeline; // Attach an event handler if defined angular.forEach(scope.events, function (callback, event) { @@ -92,7 +94,8 @@ angular.module('ngVis', []) scope: { data: '=', options: '=', - events: '=' + events: '=', + component: '=' }, link: function (scope, element, attr) { var networkEvents = [ @@ -103,6 +106,7 @@ angular.module('ngVis', []) ]; var network = new vis.Network(element[0], scope.data, scope.options); + scope.component = network; scope.$watch('data', function () { // Sanity check @@ -118,6 +122,7 @@ angular.module('ngVis', []) // Create the graph2d object network = new vis.Network(element[0]); + scope.component = network; // Attach an event handler if defined angular.forEach(scope.events, function (callback, event) { @@ -166,7 +171,8 @@ angular.module('ngVis', []) scope: { data: '=', options: '=', - events: '=' + events: '=', + component: '=' }, link: function (scope, element, attr) { var graphEvents = [ @@ -178,6 +184,7 @@ angular.module('ngVis', []) // Create the chart var graph = new vis.Graph2d(element[0]); + scope.component = graph; scope.$watch('data', function () { // Sanity check @@ -193,6 +200,7 @@ angular.module('ngVis', []) // Create the graph2d object graph = new vis.Graph2d(element[0]); + scope.component = graph; // Attach an event handler if defined angular.forEach(scope.events, function (callback, event) {