我需要帮助让this plunker在angularjs中与this vis example类似。
我正在使用<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%'
};
没有控制台错误,我错过了什么。请帮忙。
答案 0 :(得分:8)
您的数据是普通对象,但是nodes
&amp; 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 here。