MCPcopy
hub / github.com/apache/echarts / parseNodes

Function parseNodes

extension-src/dataTool/gexf.ts:73–145  ·  view source on GitHub ↗
(parent, attributesMap)

Source from the content-addressed store, hash-verified

71}
72
73function parseNodes(parent, attributesMap) {
74 return parent ? zrUtil.map(getChildrenByTagName(parent, 'node'), function (nodeDom) {
75
76 const id = getAttr(nodeDom, 'id');
77 const label = getAttr(nodeDom, 'label');
78
79 const node = {
80 id: id,
81 name: label,
82 itemStyle: {
83 normal: {}
84 }
85 };
86
87 const vizSizeDom = getChildByTagName(nodeDom, 'viz:size');
88 const vizPosDom = getChildByTagName(nodeDom, 'viz:position');
89 const vizColorDom = getChildByTagName(nodeDom, 'viz:color');
90 // let vizShapeDom = getChildByTagName(nodeDom, 'viz:shape');
91
92 const attvaluesDom = getChildByTagName(nodeDom, 'attvalues');
93
94 if (vizSizeDom) {
95 node.symbolSize = parseFloat(getAttr(vizSizeDom, 'value'));
96 }
97 if (vizPosDom) {
98 node.x = parseFloat(getAttr(vizPosDom, 'x'));
99 node.y = parseFloat(getAttr(vizPosDom, 'y'));
100 // z
101 }
102 if (vizColorDom) {
103 node.itemStyle.normal.color = 'rgb(' + [
104 getAttr(vizColorDom, 'r') | 0,
105 getAttr(vizColorDom, 'g') | 0,
106 getAttr(vizColorDom, 'b') | 0
107 ].join(',') + ')';
108 }
109 // if (vizShapeDom) {
110 // node.shape = getAttr(vizShapeDom, 'shape');
111 // }
112 if (attvaluesDom) {
113 const attvalueDomList = getChildrenByTagName(attvaluesDom, 'attvalue');
114
115 node.attributes = {};
116
117 for (let j = 0; j < attvalueDomList.length; j++) {
118 const attvalueDom = attvalueDomList[j];
119 const attId = getAttr(attvalueDom, 'for');
120 let attValue = getAttr(attvalueDom, 'value');
121 const attribute = attributesMap[attId];
122
123 if (attribute) {
124 switch (attribute.type) {
125 case 'integer':
126 case 'long':
127 attValue = parseInt(attValue, 10);
128 break;
129 case 'float':
130 case 'double':

Callers 1

parseFunction · 0.85

Calls 4

getChildrenByTagNameFunction · 0.85
getAttrFunction · 0.85
getChildByTagNameFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…