使用 JIT 显示非常大的图

发布于 2024-11-02 13:35:37 字数 1370 浏览 0 评论 0原文

我想在网页中向用户显示单向图。我目前使用 JavaScript InfoVis Toolkit (JIT) 作为可视化库。

问题是该图有很多节点和边,浏览器无法跟上所有节点和边,速度会变慢。这是a部分图的屏幕截图:

Screenshot of the graph with Many Node

我认为如果该图可以解决问题已部分显示。因此,当用户单击某个节点时,该节点及其周围的节点应展开(显示),而一些较远的节点应折叠(隐藏),以防止出现性能问题。

基于这个想法,我编写了一个简单的代码,当用户单击它时展开节点并将其置于中心并折叠先前居中的节点。这不是一种非常有效和明智的显示节点的方式,无论如何它都不起作用。它只是折叠所有节点,而无法展开当前单击的节点。

这是代码:

onClick: function(node,eventInfo,e) {
    if(node==false) 
    {
        return;
    }

    if(rgraph.previousexpand!=false)
    {
        if(rgraph.previousexpand.id!=node.id)
        {
            rgraph.op.contract(rgraph.previousexpand, {  
                type: 'animate',  
                duration: 3000,  
                hideLabels: true,  
                transition: $jit.Trans.Quart.easeOut  
            });                 
        }
    }

    rgraph.previousexpand = node;
    rgraph.op.expand(rgraph.previousexpand, {  
       type: 'animate',  
       duration: 3000,  
       hideLabels: true,  
       transition: $jit.Trans.Quart.easeOut  
    }); 

    rgraph.onClick(node.id);
}

在初始化中:

rgraph.previousexpand=false;

首先,您知道显示非常大的图形的更好方法吗? JIT 或其他库中是否有其他解决方案以这种方式显示图形?

其次,我在代码中缺少什么?

I want to show a unidirectional graph to the user in a webpage. I am currently using JavaScript InfoVis Toolkit (JIT) as the visulization library.

The problem is that the graph has many nodes and edges and the browser cannot keep up with all of it and slows down. Here is a screenshot of part a graph:

Screenshot of the graph with many nodes

I think the problem will be solved if the graph is shown partially. So when user clicks on a node that node and nodes around it should be expanded (shown) and some far nodes should be collapsed (hidden) to prevent performance issues.

Based on this idea I I've written a simple code that expands a node and puts it in center when a user clicks on it and collapse previous centered node. It is not a very efficient and wise way for showing nodes, anyway it doesn't work. It just collapses all the nodes and fails to expand the current clicked node.

Here is the code:

onClick: function(node,eventInfo,e) {
    if(node==false) 
    {
        return;
    }

    if(rgraph.previousexpand!=false)
    {
        if(rgraph.previousexpand.id!=node.id)
        {
            rgraph.op.contract(rgraph.previousexpand, {  
                type: 'animate',  
                duration: 3000,  
                hideLabels: true,  
                transition: $jit.Trans.Quart.easeOut  
            });                 
        }
    }

    rgraph.previousexpand = node;
    rgraph.op.expand(rgraph.previousexpand, {  
       type: 'animate',  
       duration: 3000,  
       hideLabels: true,  
       transition: $jit.Trans.Quart.easeOut  
    }); 

    rgraph.onClick(node.id);
}

And in initialization:

rgraph.previousexpand=false;

First, do you know any better way for showing a very large graph? Is there any other solution in JIT or maybe other library that show graph in this way?

Second, what i am missing in the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文