3

我需要帮助来使这个 plunker工作类似于angularjs 中的这个 vis 示例

我正在使用<vis-network data="data" options="options"></vis-network>标签及以下数据和选项

数据

var nodes = [
  {id: 1, label: 'Node 1'},
  {id: 2, label: 'Node 2'},
  {id: 3, label: 'Node 3'},
  {id: 4, label: 'Node 4'},
  {id: 5, label: 'Node 5'}
];
var edges = [
  {from: 1, to: 3},
  {from: 1, to: 2},
  {from: 2, to: 4},
  {from: 2, to: 5}
];
$scope.data = VisDataSet({
  nodes: nodes,
  edges: edges
});

选项

$scope.options = {
  autoResize: true,
  height: '100%',
  width: '100%'
};

没有控制台错误,我错过了什么。请帮忙。

4

1 回答 1

8

您的数据是普通对象,但是nodes&edges应该是VisDataSet

var nodes = VisDataSet([
  {id: 1, label: 'Node 1'},
  {id: 2, label: 'Node 2'},
  {id: 3, label: 'Node 3'},
  {id: 4, label: 'Node 4'},
  {id: 5, label: 'Node 5'}
]);
var edges = VisDataSet([
  {from: 1, to: 3},
  {from: 1, to: 2},
  {from: 2, to: 4},
  {from: 2, to: 5}
]);
$scope.data = {
  nodes: nodes,
  edges: edges
};

我在这里更新了你的 plunker

于 2015-06-24T11:38:06.993 回答