Skip to content

Commit

Permalink
Add component attribute to be able to easily interact with the visual…
Browse files Browse the repository at this point in the history
…ization component.

For example with this new attribute is possible to do something like:
<vis-network component="component"/>

$scope.component.selectNodes("1");
  • Loading branch information
Roger Abelenda committed May 2, 2015
1 parent dc45961 commit d2989ef
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions angular-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ angular.module('ngVis', [])
scope: {
data: '=',
options: '=',
events: '='
events: '=',
component: '='
},
link: function (scope, element, attr) {
var timelineEvents = [
Expand All @@ -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) {
Expand Down Expand Up @@ -92,7 +94,8 @@ angular.module('ngVis', [])
scope: {
data: '=',
options: '=',
events: '='
events: '=',
component: '='
},
link: function (scope, element, attr) {
var networkEvents = [
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -166,7 +171,8 @@ angular.module('ngVis', [])
scope: {
data: '=',
options: '=',
events: '='
events: '=',
component: '='
},
link: function (scope, element, attr) {
var graphEvents = [
Expand All @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit d2989ef

Please sign in to comment.