johnnyflinn / ngCytoscape

Angular directive for cytoscape.js
http://johnnyflinn.github.io/ngCytoscape
MIT License
17 stars 18 forks source link

Graph changes not updated #18

Closed atoftegaard closed 7 years ago

atoftegaard commented 8 years ago

Hi It seems changes to edges, are not reflected on the graph. When loading, the graph is drawn as expected, but later adding/removal of edges seem ignored.

I have tried extending the changes on the nodes object, as in the demo - without any luck. What could be the problem?

johnnyflinn commented 7 years ago

Not enough info.

ericmarcos commented 7 years ago

Same problem here:

<cytoscape flex graph-elements="graph.elements" graph-layout="graph.layout" graph-style="graph.styles"></cytoscape>
<button ng-click="onClick()">Test</button>
{{graph.elements | json}}
$scope.graph = {
  elements: [
    {'data':{'id':'1', 'name':'1'}},
    {'data':{'id':'2', 'name':'2'}},
    {'data':{'id':'3', 'name':'3'}},
    {'data':{'source': '1', 'target': '2'}},
    {'data':{'source': '2', 'target': '3'}}
  ],
  layout: {...},
  styles: [...]
};
$scope.onClick = function() {
  $scope.graph.elements.pop();
};

You'll see how the edges disappear from the canvas, but not the nodes, despite they're really removed from the elements array.

johnnyflinn commented 7 years ago

Elements should be an object map, not an array of objects. I wanted to realign this directive more closely with Cytoscape's Array of Objects, like you posted, I just haven't gotten around to it.