Skip to content

Commit

Permalink
Merge pull request #22 from rabelenda/master
Browse files Browse the repository at this point in the history
Add component attribute to be able to easily interact with the visualization component
  • Loading branch information
cdjackson committed May 2, 2015
2 parents dc45961 + d2989ef commit 90d0c43
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions angular-vis.js
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 90d0c43

Please sign in to comment.