随笔 - 45,  文章 - 0,  评论 - 0,  阅读 - 66947

1、计算最外层最大节点个数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function getMaxLeafCnt(data) {
        var maxcnt = 0;//本身
        var children = data.children == undefined ? new Array() : data.children;
        if (children.length > 0) {
            for (var i = 0; i < children.length; i++) {
                var f = children[i];
                if (f.children == undefined) {
                    maxcnt++;
                } else {
                    maxcnt += getMaxLeafCnt(f);
                }
            }
        }
        return maxcnt;
    }

2、树形布局,无须自己计算位置:

1
2
// 树形布局
scene.doLayout(JTopo.layout.TreeLayout('down', 30, 107));

3、设置警告:

1
2
3
4
5
6
7
8
9
10
setInterval(function () {
        for (var i = 0; i < nodeAlarms.length; i++) {
            var s = nodeAlarms[i];
            if (s.alarm == '二级告警') {
                s.alarm = null;
            } else {
                s.alarm = '二级告警'
            }
        }
    }, 600);

 

posted on   time_on  阅读(434)  评论(0编辑  收藏  举报

点击右上角即可分享
微信分享提示