Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Support for dataset #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions addon/components/visjs-edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ export default VisJsChild.extend({
return `${this.get('from')}-${this.get('to')}`;
}),

/**
* @public
*
* If set this defines edge's weight (thickness).
* @type {Int}
*/
value: undefined,

valueChanged: Ember.observer('value', function() {
let container = this.get('containerLayer');
container.updateEdgeValue(this.get('eId'), this.get('value'));
}),

/**
* @public
*
* If set this defines edge's color
* @type {Int}
*/
color: undefined,

colorChanged: Ember.observer('color', function() {
let container = this.get('containerLayer');
container.updateEdgeColor(this.get('eId'), this.get('color'));
}),

arrowChanged: Ember.observer('arrows', function() {
let container = this.get('containerLayer');
container.updateEdgeArrow(this.get('eId'), this.get('arrows'));
Expand Down
21 changes: 20 additions & 1 deletion addon/components/visjs-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default Ember.Component.extend(ContainerMixin, {
this._super(...arguments);

this.set('nodes', new vis.DataSet([]));
this.set('edges', new vis.DataSet([]));
this.set('edges', new vis.DataSet(this.get('edgesSet')));
},

didInsertElement() {
Expand All @@ -32,6 +32,13 @@ export default Ember.Component.extend(ContainerMixin, {
options
);

if(this.get('nodesSet') && this.get('edgesSet')) {
network.setData({
nodes: this.get('nodesSet'),
edges: this.get('edgesSet')
});
}

let _this = this;

network.on('selectNode', (e) => {
Expand Down Expand Up @@ -170,6 +177,10 @@ export default Ember.Component.extend(ContainerMixin, {
simplifiedNode.y = node.get('posY');
}

if (node.get('value') || node.get('value') === 0) {
simplifiedNode.value = node.get('value');
}

if (node.get('image')) {
simplifiedNode.shape = 'image';
simplifiedNode.image = node.get('image');
Expand All @@ -186,6 +197,14 @@ export default Ember.Component.extend(ContainerMixin, {
simplifiedEdge.arrows = edge.get('arrows');
}

if (edge.get('value')) {
simplifiedEdge.value = edge.get('value');
}

if (edge.get('color')) {
simplifiedEdge.color = edge.get('color');
}

edges.add(simplifiedEdge);
},

Expand Down
13 changes: 13 additions & 0 deletions addon/components/visjs-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ export default VisJsChild.extend({
imageChanged: Ember.observer('image', function() {
let container = this.get('containerLayer');
container.updateNodeImage(this.get('nId'), this.get('image'));
}),

/**
* @public
*
* If set, a value would be set to alter node's size
* @type {Number}
*/
value: false,

valueChanged: Ember.observer('value', function() {
let container = this.get('containerLayer');
container.updateNodeValue(this.get('nId'), this.get('value'));
})

});