本文介绍了将链接附加到 3d-force-graph 节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将链接附加到 3d-force-graph 中的节点(https://github.com/vasturiano/3d-force-graph) 这样如果用户点击一个节点,他们就会被带到一个特定的(或自定义的)url?

Is there a way to attach a link to the nodes in 3d-force-graph (https://github.com/vasturiano/3d-force-graph) so that if a user clicks on a node they are taken away to a specific (or customised) url?

推荐答案

答案在 .onNodeClick 函数中.例如,添加指向您的 json 的链接:

The answer is found in the .onNodeClick function. For example, add a link to your json:

'nodes': [
    {
    "id": "id1",
    "name": "<h2>Title 1</h2>",
    "val": 1,
    'link': 'test.html?id=1',
    },

并将以下内容添加到您的图形对象中:

And add the following to your graph object:

.onNodeClick(function(node){
    window.location.href = node.link;
})

这篇关于将链接附加到 3d-force-graph 节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 14:05