View unanswered posts | View active topics It is currently 2020-09-19 8:12



Reply to topic  [ 4 posts ] 
 关于连线的奇葩情况 
Author Message
初级会员

Joined: 2017-12-04 9:31
Posts: 130
Post 关于连线的奇葩情况
1. 我创建了11条连线,界面只能看到 9条 少了两条
2. 一直在找原因,就是找不到原因,我就把连线 设置名字;
3. 果然名字 显示出来了,但名字位置也不对,且少的两条连线还是看不到;
4.当点击到那名字时,连线就显示出来了

能给个解释


Attachments:
xxx1.png
xxx1.png [ 48.74 KiB | Viewed 1156 times ]
xxx2.png
xxx2.png [ 53.61 KiB | Viewed 1156 times ]
2019-11-27 9:39
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 424
Post Re: 关于连线的奇葩情况
不好意思现在才回复您,您可以看下数据中对应的link的from和to节点是否有问题,最好是能把代码贴出来一起解决。


2019-12-16 15:07
Profile
初级会员

Joined: 2017-12-04 9:31
Posts: 130
Post Re: 关于连线的奇葩情况
经过长时间摸索 找到问题所在了
定义连线
var link = new twaver.Link({id:id,fromNode: fromNode,toNode:toNode})
这样创建会出现上述情况,并且根据Node查找node.getLinks() 会查找连线不全;
只有这样定义
link.setFromNode(fromNode)
link.setToNode(toNode)
才ok;

能否给个解释为啥会出现这种情况


2019-12-16 23:50
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 424
Post Re: 关于连线的奇葩情况
创建link的方式是这样的:new twaver.Link(id, from, to);
我看您贴的代码传的是个对象,您再重新试试。
我这边用new twaver.Link(id, from, to)创建的方式是可以的。
Code:
<!DOCTYPE html>
<html>

  <head>
    <title>TWaver HTML5 Demo</title>
    <script src="../js/twaver.js" type="text/javascript"></script>

    <script>
      var box = new twaver.ElementBox();
      var network = new twaver.vector.Network(box);

      function init() {
        initNetwork();
        initBox();
      }

      function initNetwork() {
        document.body.appendChild(network.getView());
        network.adjustBounds({
          x: 0,
          y: 0,
          width: document.documentElement.clientWidth,
          height:  document.documentElement.clientHeight
        });
      }

      function initBox() {
        let root = new twaver.Node();
        root.setLocation(document.documentElement.clientWidth / 2,200);
        box.add(root);

        for(let i = 0; i < 15; i++) {
          let node = new twaver.Node();
          node.setLocation(200 + 100 * i, 400);
          box.add(node);
          createLink('link' + i, root, node);
        }
      }

      function createLink(id, from, to) {
        var link = new twaver.Link(id, from, to);
        link.setName(id);
        box.add(link);
        return link;
      }
 
    </script>
    </script>
    <body onload="init();" style="margin:0;">
    </body>
</html>


2019-12-17 17:18
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron