首页 > 代码库 > mxGraph图形树节点前台数据组装

mxGraph图形树节点前台数据组装

   topoData:  数节点格式数据    

    $.each(topoData, function (_xx, _currentNode) {
                        var nowRow = _currentNode;
                        var fillColorChild = "#D2E9FF";
                        var _nowMap = _currentNode.extendMap;
                        var parentNodeValue = http://www.mamicode.com/_currentNode.parentNode;
                        var _alarmDealTime = 0.800;//默认阀值
//              console.log(_currentNode );
                        if (parentNodeValue =http://www.mamicode.com/= null) {
                            var _findKey1 = _nowMap.OP_CODE + "#" + _nowMap.REGION_CODE + "#" + _nowMap.CHANNEL_CODE + "#" + _currentNode.nodeName;
                            var _nowDealTime = _currentNode.allDealTime;
                            var traceStatus = _currentNode.extendMap.TRACE_STATUS;
                            //如果有阀值配置 判断是否超过 当前的阀值
                            if (alarmConfMap.get(_findKey1) != null && parseFloat(alarmConfMap.get(_findKey1))) {
                                _alarmDealTime = parseFloat(alarmConfMap.get(_findKey1));
                            }
                            //如果超出阀值 则显示红色
                            if (parseFloat(_alarmDealTime) < parseFloat(_nowDealTime)) {
                                fillColorChild = "yellow";
                            }
                            //如果存在错误,则显示红色
                            if (traceStatus == "1" || traceStatus == "2") {
                                fillColorChild = "red";
                            }
//                    _nowNode = graph.insertVertex(parent, ‘‘, _currentNode.nodeName + "\n" + _nowDealTime + "(s)", 0, 0, childNodeHeight, childNodeWidth, ‘fillColor=‘ + fillColorChild + ‘;[param]level=‘ + _currentNode.level + ‘;nowNodeName=‘ + 1 + "[/param]");
                            _nowNode = graph.insertVertex(parent, ‘‘, _currentNode.nodeName + "\n" + _nowDealTime + "(s)", 0, 0, childNodeHeight, childNodeWidth, ‘fillColor=‘ + fillColorChild);
                            graph.insertEdge(parent, ‘‘, ‘‘, _parentNodeNew, _nowNode);
                            var parentNodeNewKey = _currentNode.id + "$$" + _currentNode.allDealTime;
                            parentNameMap.put(parentNodeNewKey, _nowNode);
                            parentNodeMap.put(parentNodeNewKey, _nowNode)
                        } else {
                            var childNodeKey = _currentNode.id + "$$" + _currentNode.allDealTime;
                            var parentNodeKey = parentNodeValue.pid + "$$" + parentNodeValue.allDealTime;
                            var nowNodeName = _currentNode.nodeName + "\n" + _currentNode.allDealTime + "(s)";
                            var parentNodeName = parentNodeValue.nodeName + "\n" + parentNodeValue.allDealTime + "(s)";
                            if (parentNameMap.get(parentNodeKey) != null) {
                                _parentNode = parentNodeMap.get(parentNodeKey);
                            } else {
                                if (childNodeMap.get(parentNodeKey) != null) {
                                    _parentNode = childNodeMap.get(parentNodeKey);
                                } else {
                                    var _nowNewMap = parentNodeValue.extendMap;
                                    var _findNewKey1 = _nowNewMap.OP_CODE + "#" + _nowNewMap.REGION_CODE + "#" + _nowNewMap.CHANNEL_CODE + "#" + parentNodeValue.nodeName;
                                    var _nowDealTime = parentNodeValue.allDealTime;
                                    var traceStatus = parentNodeValue.extendMap.TRACE_STATUS;
                                    //如果有阀值配置 判断是否超过 当前的阀值
                                    if (alarmConfMap.get(_findNewKey1) != null && parseFloat(alarmConfMap.get(_findNewKey1))) {
                                        _alarmDealTime = parseFloat(alarmConfMap.get(_findNewKey1));
                                    }
                                    if (parseFloat(_nowDealTime) > parseFloat(_alarmDealTime)) {
                                        fillColorChild = "yellow";
                                    }
                                    if (traceStatus == "1" || traceStatus == "2") {
                                        fillColorChild = "red";
                                    }

                                    if (parentNodeName.indexOf(":") != -1) {
                                        var _tempIndex = parentNodeName.indexOf(":");
                                        parentNodeName = parentNodeName.substr(_tempIndex + 1, parentNodeName.length);

                                    }
                                    _parentNode = graph.insertVertex(parent, ‘‘, parentNodeName, rootNodeXValue, rootNodeYValue, rootNodeHeight, rootNodeWidth, ‘fillColor=‘ + fillColorChild);

//                            _parentNode = graph.insertVertex(parent, ‘‘, parentNodeName, rootNodeXValue, rootNodeYValue, rootNodeHeight, rootNodeWidth, ‘fillColor=‘ + fillColorChild + ‘;[param]level=7;parentNodeName=‘ + parentNodeKey + "[/param]");
                                }
                            }
                            if (childNameMap.get(childNodeKey) != null) {
                                _nowNode = childNameMap.get(childNodeKey);
                            } else {
                                if (parentNameMap.get(childNodeKey) != null) {
                                    _nowNode = parentNodeMap.get(parentNodeKey);
                                } else {
                                    var _nowNewMap = _currentNode.extendMap;
                                    var _findNewKey1 = _nowNewMap.OP_CODE + "#" + _nowNewMap.REGION_CODE + "#" + _nowNewMap.CHANNEL_CODE + "#" + _currentNode.nodeName;
                                    //如果有阀值配置 判断是否超过 当前的阀值
                                    if (alarmConfMap.get(_findNewKey1) != null && parseFloat(alarmConfMap.get(_findNewKey1))) {
                                        _alarmDealTime = parseFloat(alarmConfMap.get(_findNewKey1));
                                    }
                                    if (parseFloat(_currentNode.allDealTime) > parseFloat(_alarmDealTime)) {
                                        fillColorChild = "yellow";
                                    }
                                    if (_currentNode.extendMap.TRACE_STATUS == "1" || _currentNode.extendMap.TRACE_STATUS == "2") {
                                        fillColorChild = "red";
                                    }

                                    if (nowNodeName.indexOf(":") != -1) {
                                        var _tempIndex = nowNodeName.indexOf(":");
                                        nowNodeName = nowNodeName.substr(_tempIndex + 1, nowNodeName.length);
                                    }
//                            _nowNode = graph.insertVertex(parent, ‘‘, nowNodeName, 0, 0, childNodeHeight, childNodeWidth, ‘fillColor=‘ + fillColorChild + ‘;[param]level=‘ + _currentNode.level + ‘;nowNodeName=‘ + childNodeKey + "[/param]");

                                    _nowNode = graph.insertVertex(parent, ‘‘, nowNodeName, 0, 0, childNodeHeight, childNodeWidth, ‘fillColor=‘ + fillColorChild);
                                }
                            }
                            graph.insertEdge(parent, ‘‘, ‘‘, _parentNode, _nowNode);
                            //判断根节点是否需要重新创建
                            if (childNameMap.get(childNodeKey) != null) {
                                _nowNode = childNodeMap.get(childNodeKey);
                            } else {
                                if (parentNameMap.get(childNodeKey) != null) {
                                    _nowNode = parentNodeMap.get(parentNodeKey);
                                } else {
                                    childNodeMap.put(childNodeKey, _nowNode);
                                }
                            }
                        }
                    });

 

mxGraph图形树节点前台数据组装