gpt4 book ai didi

angularjs - 需要帮助在 angularjs 中使用 visjs 创建网络图

转载 作者:行者123 更新时间:2023-12-02 23:07:06 26 4
gpt4 key购买 nike

我需要帮助来制作 this plunker做类似 this vis example 的事情在 AngularJS 中。

我正在使用<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%'
};

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

最佳答案

您的数据是普通对象,但是nodesedges应该是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 .

关于angularjs - 需要帮助在 angularjs 中使用 visjs 创建网络图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31019327/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com