|
@@ -242,26 +242,6 @@ export default {
|
|
|
return 60;
|
|
|
},
|
|
|
|
|
|
- // type: 'force',
|
|
|
- // preventOverlap: true,
|
|
|
- // linkDistance: (d) => {
|
|
|
- // if (d.source.id === 'node0') {
|
|
|
- // return 300;
|
|
|
- // }
|
|
|
- // return 60;
|
|
|
- // },
|
|
|
- // nodeStrength: (d) => {
|
|
|
- // if (d.isLeaf) {
|
|
|
- // return -50;
|
|
|
- // }
|
|
|
- // return -10;
|
|
|
- // },
|
|
|
- // edgeStrength: (d) => {
|
|
|
- // if (d.source.id === 'node1' || d.source.id === 'node2' || d.source.id === 'node3') {
|
|
|
- // return 0.7;
|
|
|
- // }
|
|
|
- // return 0.1;
|
|
|
- // },
|
|
|
},
|
|
|
};
|
|
|
|
|
@@ -273,20 +253,6 @@ export default {
|
|
|
{
|
|
|
shapeType: 'flow-rect',
|
|
|
draw(cfg, group) {
|
|
|
- // const {
|
|
|
- // name = '',
|
|
|
- // variableName,
|
|
|
- // variableValue,
|
|
|
- // variableUp,
|
|
|
- // label,
|
|
|
- // collapsed,
|
|
|
- // currency,
|
|
|
- // status,
|
|
|
- // rate
|
|
|
- // } = cfg;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
const {
|
|
|
name = '',
|
|
|
// variableName,
|
|
@@ -388,33 +354,6 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- // percentage triangle
|
|
|
- // const symbol = variableUp ? 'triangle' : 'triangle-down';
|
|
|
- // const triangle = group.addShape('marker', {
|
|
|
- // attrs: {
|
|
|
- // ...textConfig,
|
|
|
- // x: percentText.getBBox().minX - 10,
|
|
|
- // y: rectBBox.maxY - 12 - 6,
|
|
|
- // symbol,
|
|
|
- // r: 6,
|
|
|
- // fill: colors[status],
|
|
|
- // },
|
|
|
- // });
|
|
|
-
|
|
|
- // variable name
|
|
|
- // group.addShape('text', {
|
|
|
- // attrs: {
|
|
|
- // ...textConfig,
|
|
|
- // x: triangle.getBBox().minX - 4,
|
|
|
- // y: rectBBox.maxY - 12,
|
|
|
- // text: variableName,
|
|
|
- // fontSize: 12,
|
|
|
- // textAlign: 'right',
|
|
|
- // fill: '#000',
|
|
|
- // opacity: 0.45,
|
|
|
- // },
|
|
|
- // });
|
|
|
-
|
|
|
// bottom line background
|
|
|
const bottomBackRect = group.addShape('rect', {
|
|
|
attrs: {
|
|
@@ -583,15 +522,6 @@ export default {
|
|
|
const midPoint = shape.getPoint(0.5);
|
|
|
const iconDown = _this.iconDown;
|
|
|
|
|
|
- // group.addShape('circle', {
|
|
|
- // attrs: {
|
|
|
- // r: 8,
|
|
|
- // fill: '#1890ff',
|
|
|
- // x: midPoint.x - 8,
|
|
|
- // y: midPoint.y - 16,
|
|
|
- // cursor: 'pointer',
|
|
|
- // },
|
|
|
- // });
|
|
|
const visible = cfg.sourceNode._cfg.model.span_id == 'UNKNOWN SPAN ID' || cfg.targetNode._cfg.model.span_id == '' ? false : true;
|
|
|
group.addShape('image', {
|
|
|
attrs: {
|
|
@@ -606,96 +536,10 @@ export default {
|
|
|
visible,
|
|
|
name: 'name-edge-button',
|
|
|
})
|
|
|
- // // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
|
|
|
- // name: 'ip-cp-icon',
|
|
|
- // });
|
|
|
- // const rectColor = cfg.midPointColor || '#333';
|
|
|
- // add a rect on the mid point of the path. note that the origin of a rect shape is on its lefttop
|
|
|
- // 在中点增加一个矩形,注意矩形的原点在其左上角
|
|
|
-
|
|
|
- // group.addShape('rect', {
|
|
|
- // attrs: {
|
|
|
- // width: 20,
|
|
|
- // height: 12,
|
|
|
- // fill: '#1890ff',
|
|
|
- // padding:[2,4],
|
|
|
- // // x and y should be minus width / 2 and height / 2 respectively to translate the center of the rect to the midPoint
|
|
|
- // // x 和 y 分别减去 width / 2 与 height / 2,使矩形中心在 midPoint 上
|
|
|
- // x: midPoint.x - 10,
|
|
|
- // y: midPoint.y - 6,
|
|
|
- // borderRadius: 2,
|
|
|
- // },
|
|
|
- // });
|
|
|
- // group.addShape('text', {
|
|
|
- // attrs: {
|
|
|
- // textAlign:'center',
|
|
|
- // x: 10 + midPoint.x - 10,
|
|
|
- // y: midPoint.y + 3,
|
|
|
- // text: '点击',
|
|
|
- // fontSize: 8,
|
|
|
- // opacity: 1,
|
|
|
- // fill: '#fff',
|
|
|
- // cursor: 'pointer',
|
|
|
- // },
|
|
|
- // // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
|
|
|
- // name: 'name-edge-button',
|
|
|
- // });
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
update: undefined,
|
|
|
- // getControlPoints(cfg,group) {
|
|
|
- // let controlPoints = cfg.controlPoints; // 指定controlPoints
|
|
|
- // if (!controlPoints || !controlPoints.length) {
|
|
|
- // const { startPoint, endPoint, sourceNode, targetNode } = cfg;
|
|
|
- // const { x: startX, y: startY, coefficientX, coefficientY } = sourceNode
|
|
|
- // ? sourceNode.getModel()
|
|
|
- // : startPoint;
|
|
|
- // const { x: endX, y: endY } = targetNode ? targetNode.getModel() : endPoint;
|
|
|
- // let curveStart = (endX - startX) * coefficientX;
|
|
|
- // let curveEnd = (endY - startY) * coefficientY;
|
|
|
- // curveStart = curveStart > 40 ? 40 : curveStart;
|
|
|
- // curveEnd = curveEnd < -30 ? curveEnd : -30;
|
|
|
- // controlPoints = [
|
|
|
- // { x: startPoint.x + curveStart, y: startPoint.y },
|
|
|
- // { x: endPoint.x + curveEnd, y: endPoint.y },
|
|
|
- // ];
|
|
|
- // }
|
|
|
- // return controlPoints;
|
|
|
- // },
|
|
|
- // getPath(points) {
|
|
|
- // const path = [];
|
|
|
- // path.push(['M', points[0].x, points[0].y]);
|
|
|
- // path.push([
|
|
|
- // 'C',
|
|
|
- // points[1].x,
|
|
|
- // points[1].y,
|
|
|
- // points[2].x,
|
|
|
- // points[2].y,
|
|
|
- // points[3].x,
|
|
|
- // points[3].y,
|
|
|
- // ]);
|
|
|
- // return path;
|
|
|
- // },
|
|
|
- // // 响应状态变化
|
|
|
- // setState(name, value, item) {
|
|
|
- // const group = item.getContainer();
|
|
|
- // const shape = group.get('children')[0]; // 顺序根据 draw 时确定
|
|
|
- // if (name === 'active') {
|
|
|
- // if (value) {
|
|
|
- // shape.attr('stroke', 'red');
|
|
|
- // } else {
|
|
|
- // shape.attr('stroke', '#333');
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (name === 'selected') {
|
|
|
- // if (value) {
|
|
|
- // shape.attr('lineWidth', 3);
|
|
|
- // } else {
|
|
|
- // shape.attr('lineWidth', 2);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
- // update: undefined,
|
|
|
},
|
|
|
'single-line',
|
|
|
);
|
|
@@ -729,21 +573,8 @@ export default {
|
|
|
outDiv.innerHTML = `${formatedNodeName}`;
|
|
|
return outDiv;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
- // shouldBegin: (e) => {
|
|
|
- // if (e.target.get('name') === 'name-shape' || e.target.get('name') === 'mask-label-shape') return true;
|
|
|
- // return false;
|
|
|
- // },
|
|
|
});
|
|
|
- // graph = new G6.TreeGraph({
|
|
|
- // container: 'container',
|
|
|
- // ...defaultConfig,
|
|
|
- // ...config,
|
|
|
- // plugins: [tooltip],
|
|
|
- // });
|
|
|
|
|
|
graph = new G6.TreeGraph({
|
|
|
container: id,
|
|
@@ -755,36 +586,11 @@ export default {
|
|
|
if (typeof onInit === 'function') {
|
|
|
onInit(graph);
|
|
|
}
|
|
|
- // graph.on("afterrender", () => {
|
|
|
- // // graph.zoom(0.2, { x: width / 2, y: height / 2 });
|
|
|
- // graph.zoom(0.5, { x: width / 2, y: height / 2 });
|
|
|
- // });
|
|
|
graph.data(data);
|
|
|
graph.render();
|
|
|
-
|
|
|
- // setTimeout(() => {
|
|
|
- // // 1 默认展开三层节点,之后,重新渲染,item.depth > 1是三层,item.depth > 0是两层
|
|
|
- // G6.Util.traverseTree(data, function(item) {
|
|
|
- // if (item.depth > 1) {
|
|
|
- // //collapsed为true时默认收起
|
|
|
- // item.collapsed = true
|
|
|
- // }
|
|
|
- // })
|
|
|
- // graph.render()
|
|
|
- // // graph.fitCenter() // 移到图中心
|
|
|
- // }, 10)
|
|
|
- // setTimeout(() => {
|
|
|
- // graph.fitCenter() // 移到图中心
|
|
|
- // }, 10)
|
|
|
//添加点击事件
|
|
|
graph.on("node:click", (evt) => {
|
|
|
const item = evt.item;
|
|
|
- // animately move the graph to focus on the item.
|
|
|
- // the second parameter controlls whether move with animation, the third parameter is the animate configuration
|
|
|
- // graph.focusItem(item, true, {
|
|
|
- // easing: 'easeCubic',
|
|
|
- // duration: 500,
|
|
|
- // });
|
|
|
|
|
|
|
|
|
const itemData = evt.item._cfg.model;
|
|
@@ -838,45 +644,9 @@ export default {
|
|
|
this.$message('暂无数据')
|
|
|
}
|
|
|
})
|
|
|
- // this.$http({
|
|
|
- // // url: 'http://df-app.cestong.com.cn/v1/stats/querier/network-spans',
|
|
|
- // url:'http://app.cestong.com.cn/v1/stats/querier/network-spans',
|
|
|
- // method: 'post',
|
|
|
- // data:this.networkQuery
|
|
|
- // }).then(res=>{
|
|
|
-
|
|
|
- // if(res.data.OPT_STATUS.length!=0){
|
|
|
- // let optList = this.handleData(res.data.OPT_STATUS);
|
|
|
- // let newOptList = this.buildNestedTree(optList);
|
|
|
-
|
|
|
- // newFirstNode.children = newOptList;
|
|
|
-
|
|
|
-
|
|
|
- // let firstList =[newFirstNode];
|
|
|
-
|
|
|
- // let resultList = this.addDataToTree(firstList,newLastNode)
|
|
|
-
|
|
|
- // topoData = resultList[0]
|
|
|
-
|
|
|
-
|
|
|
- // this.networkOpen = true;
|
|
|
- // this.flag = true;
|
|
|
- // setTimeout(()=>{
|
|
|
- // this.initGraphNetwork(topoData,'networkContainer')
|
|
|
- // },300)
|
|
|
-
|
|
|
-
|
|
|
- // }else{
|
|
|
- // this.$message('暂无数据')
|
|
|
- // }
|
|
|
- // })
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
- // 双击节点进行跳转
|
|
|
- // graph.on("node:dblclick", (evt) => {
|
|
|
- // const itemData = evt.item._cfg.model;
|
|
|
- // const { level, id } = itemData;
|
|
|
- // });
|
|
|
|
|
|
const handleCollapse = (e) => {
|
|
|
const target = e.target;
|
|
@@ -898,45 +668,6 @@ export default {
|
|
|
handleCollapse(e);
|
|
|
});
|
|
|
|
|
|
- // 监听画布缩放,缩小到一定程度,节点显示缩略样式
|
|
|
- // let currentLevel = 1;
|
|
|
- // const briefZoomThreshold = Math.max(graph.getZoom(), 0.5);
|
|
|
- // graph.on('viewportchange', e => {
|
|
|
- // if (e.action !== 'zoom') return;
|
|
|
- // const currentZoom = graph.getZoom();
|
|
|
- // let toLevel = currentLevel;
|
|
|
- // if (currentZoom < briefZoomThreshold) {
|
|
|
- // toLevel = 0;
|
|
|
- // } else {
|
|
|
- // toLevel = 1;
|
|
|
- // }
|
|
|
- // if (toLevel !== currentLevel) {
|
|
|
- // currentLevel = toLevel;
|
|
|
- // graph.getNodes().forEach(node => {
|
|
|
- // graph.updateItem(node, {
|
|
|
- // level: toLevel
|
|
|
- // })
|
|
|
- // })
|
|
|
- // }
|
|
|
- // });
|
|
|
- // let centerNodes = graph.getNodes().filter((node) => !node.getModel().isLeaf);
|
|
|
- // graph.on('afterlayout', () => {
|
|
|
- // alert('a')
|
|
|
- // // descriptionDiv.innerHTML = '';
|
|
|
- // const hull1 = graph.createHull({
|
|
|
- // id: 'centerNode-hull',
|
|
|
- // type: 'bubble',
|
|
|
- // // members: centerNodes,
|
|
|
- // members:["1bba4a28db0ee496" ,"7ea21fafd3f684e3" ],
|
|
|
- // padding: 10,
|
|
|
- // });
|
|
|
-
|
|
|
- // graph.on('afterupdateitem', (e) => {
|
|
|
- // hull1.updateData(hull1.members);
|
|
|
- // // hull2.updateData(hull2.members);
|
|
|
- // // hull3.updateData(hull3.members);
|
|
|
- // });
|
|
|
- // })
|
|
|
|
|
|
if (typeof window !== 'undefined'){
|
|
|
window.onresize = () => {
|
|
@@ -992,17 +723,6 @@ export default {
|
|
|
{
|
|
|
shapeType: 'flow-rect',
|
|
|
draw(cfg, group) {
|
|
|
- // const {
|
|
|
- // name = '',
|
|
|
- // variableName,
|
|
|
- // variableValue,
|
|
|
- // variableUp,
|
|
|
- // label,
|
|
|
- // collapsed,
|
|
|
- // currency,
|
|
|
- // status,
|
|
|
- // rate
|
|
|
- // } = cfg;
|
|
|
const {
|
|
|
name = '',
|
|
|
// variableName,
|
|
@@ -1104,33 +824,6 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- // percentage triangle
|
|
|
- // const symbol = variableUp ? 'triangle' : 'triangle-down';
|
|
|
- // const triangle = group.addShape('marker', {
|
|
|
- // attrs: {
|
|
|
- // ...textConfig,
|
|
|
- // x: percentText.getBBox().minX - 10,
|
|
|
- // y: rectBBox.maxY - 12 - 6,
|
|
|
- // symbol,
|
|
|
- // r: 6,
|
|
|
- // fill: colors[status],
|
|
|
- // },
|
|
|
- // });
|
|
|
-
|
|
|
- // variable name
|
|
|
- // group.addShape('text', {
|
|
|
- // attrs: {
|
|
|
- // ...textConfig,
|
|
|
- // x: triangle.getBBox().minX - 4,
|
|
|
- // y: rectBBox.maxY - 12,
|
|
|
- // text: variableName,
|
|
|
- // fontSize: 12,
|
|
|
- // textAlign: 'right',
|
|
|
- // fill: '#000',
|
|
|
- // opacity: 0.45,
|
|
|
- // },
|
|
|
- // });
|
|
|
-
|
|
|
// bottom line background
|
|
|
const bottomBackRect = group.addShape('rect', {
|
|
|
attrs: {
|
|
@@ -1404,12 +1097,6 @@ export default {
|
|
|
// custom the tooltip's content
|
|
|
// 自定义 tooltip 内容
|
|
|
getContent: (e) => {
|
|
|
-
|
|
|
- // <div style='padding:10px;text-align:center'>
|
|
|
- // <img style='width:24px;height:24px;' src=${item.span_category =='apm'?this.apm:this.apis}/>
|
|
|
- // <div style='width:100%;height:100%;background:inherit;filter: blur(5px);'></div>
|
|
|
- // </div>
|
|
|
-
|
|
|
const outDiv = document.createElement('div');
|
|
|
const nodeName = e.item.getModel().name;
|
|
|
const item = e.item.getModel()
|
|
@@ -1461,17 +1148,7 @@ export default {
|
|
|
return outDiv;
|
|
|
}
|
|
|
},
|
|
|
- // shouldBegin: (e) => {
|
|
|
- // if (e.target.get('name') === 'name-shape' || e.target.get('name') === 'mask-label-shape') return true;
|
|
|
- // return false;
|
|
|
- // },
|
|
|
});
|
|
|
- // graph = new G6.TreeGraph({
|
|
|
- // container: 'container',
|
|
|
- // ...defaultConfig,
|
|
|
- // ...config,
|
|
|
- // plugins: [tooltip],
|
|
|
- // });
|
|
|
|
|
|
graph = new G6.TreeGraph({
|
|
|
container: id,
|
|
@@ -1483,99 +1160,14 @@ export default {
|
|
|
if (typeof onInit === 'function') {
|
|
|
onInit(graph);
|
|
|
}
|
|
|
- // graph.on("afterrender", () => {
|
|
|
- // // graph.zoom(0.2, { x: width / 2, y: height / 2 });
|
|
|
- // graph.zoom(0.5, { x: width / 2, y: height / 2 });
|
|
|
- // });
|
|
|
graph.data(data);
|
|
|
graph.render();
|
|
|
-
|
|
|
- // setTimeout(() => {
|
|
|
- // // 1 默认展开三层节点,之后,重新渲染,item.depth > 1是三层,item.depth > 0是两层
|
|
|
- // G6.Util.traverseTree(data, function(item) {
|
|
|
- // if (item.depth > 1) {
|
|
|
- // //collapsed为true时默认收起
|
|
|
- // item.collapsed = true
|
|
|
- // }
|
|
|
- // })
|
|
|
- // graph.render()
|
|
|
- // // graph.fitCenter() // 移到图中心
|
|
|
- // }, 10)
|
|
|
- // setTimeout(() => {
|
|
|
- // graph.fitCenter() // 移到图中心
|
|
|
- // }, 10)
|
|
|
//添加点击事件
|
|
|
graph.on("node:click", (evt) => {
|
|
|
const itemData = evt.item._cfg.model;
|
|
|
const { level, id } = itemData;
|
|
|
this.$emit("changeState", itemData);
|
|
|
});
|
|
|
- //点击线
|
|
|
- // graph.on("edge:click", (evt) => {
|
|
|
- // let itemData = evt.item._cfg.model;
|
|
|
- // let {source,target} = itemData;
|
|
|
- // let firstNode = evt.item._cfg.sourceNode._cfg.model;
|
|
|
- // firstNode.children=[];
|
|
|
- // // delete firstNode['children'];
|
|
|
- // // let firstList =[firstNode];
|
|
|
- // let lastNode = evt.item._cfg.targetNode._cfg.model;
|
|
|
- // lastNode.children=[];
|
|
|
- // // delete lastNode['children'];
|
|
|
-
|
|
|
- // // let lastList = [lastNode]
|
|
|
-
|
|
|
- // if(source != ''){
|
|
|
- // this.networkQuery.parent_span_id = source;
|
|
|
- // this.networkQuery.span_id = target;
|
|
|
-
|
|
|
- // { "span_id": "34815c406ececa6d", "parent_span_id": "3d3d247f0e376e94"}
|
|
|
- // this.networkQuery.parent_span_id = '3d3d247f0e376e94';
|
|
|
- // this.networkQuery.span_id = '34815c406ececa6d';
|
|
|
-
|
|
|
- // this.$http({
|
|
|
- // url: 'http://df-app.cestong.com.cn/v1/stats/querier/network-spans',
|
|
|
- // method: 'post',
|
|
|
- // data:this.networkQuery
|
|
|
- // }).then(res=>{
|
|
|
-
|
|
|
- // if(res.data.OPT_STATUS.length!=0){
|
|
|
-
|
|
|
- // const optList = this.handleData(res.data.OPT_STATUS);
|
|
|
- // const newOptList = this.buildNestedTree(optList);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // firstNode.children = newOptList;
|
|
|
-
|
|
|
-
|
|
|
- // let firstList =[firstNode];
|
|
|
-
|
|
|
- // let resultList = this.addDataToTree(firstList,lastNode)
|
|
|
-
|
|
|
- // const topoData = resultList[0]
|
|
|
-
|
|
|
- // // const resultList = [...firstList,...optList,...lastList];
|
|
|
-
|
|
|
- // // const topoData = this.buildNestedTree(resultList);
|
|
|
-
|
|
|
-
|
|
|
- // this.networkOpen = true;
|
|
|
- // setTimeout(()=>{
|
|
|
- // this.initGraph(topoData,'networkContainer')
|
|
|
- // },300)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // });
|
|
|
- // 双击节点进行跳转
|
|
|
- // graph.on("node:dblclick", (evt) => {
|
|
|
- // const itemData = evt.item._cfg.model;
|
|
|
- // const { level, id } = itemData;
|
|
|
- // });
|
|
|
|
|
|
const handleCollapse = (e) => {
|
|
|
const target = e.target;
|
|
@@ -1597,28 +1189,6 @@ export default {
|
|
|
handleCollapse(e);
|
|
|
});
|
|
|
|
|
|
- // 监听画布缩放,缩小到一定程度,节点显示缩略样式
|
|
|
- // let currentLevel = 1;
|
|
|
- // const briefZoomThreshold = Math.max(graph.getZoom(), 0.5);
|
|
|
- // graph.on('viewportchange', e => {
|
|
|
- // if (e.action !== 'zoom') return;
|
|
|
- // const currentZoom = graph.getZoom();
|
|
|
- // let toLevel = currentLevel;
|
|
|
- // if (currentZoom < briefZoomThreshold) {
|
|
|
- // toLevel = 0;
|
|
|
- // } else {
|
|
|
- // toLevel = 1;
|
|
|
- // }
|
|
|
- // if (toLevel !== currentLevel) {
|
|
|
- // currentLevel = toLevel;
|
|
|
- // graph.getNodes().forEach(node => {
|
|
|
- // graph.updateItem(node, {
|
|
|
- // level: toLevel
|
|
|
- // })
|
|
|
- // })
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
if (typeof window !== 'undefined'){
|
|
|
window.onresize = () => {
|
|
|
if (!graph || graph.get('destroyed')) return;
|