本文介绍了在 angularjs 中使用 visjs 创建网络图需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助让 这个 plunker 类似于 这个 vis 示例.

I need help in making this plunker work something similar to this vis example in angularjs.

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

I am using <vis-network data="data" options="options"></vis-network> tag and below data and options

数据

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%'
};

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

There is no console error, what am I missing. Please help.

推荐答案

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

Your data is plain object, however nodes & edges should be an object of 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.

这篇关于在 angularjs 中使用 visjs 创建网络图需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 03:52