未验证 提交 8d411076 编写于 作者: W whfjam 提交者: GitHub

handle the situation with VNode (#338)

上级 e2f00499
...@@ -137,7 +137,7 @@ limitations under the License. --> ...@@ -137,7 +137,7 @@ limitations under the License. -->
return arr; return arr;
}, },
traverseTree(node, spanId, segmentId, data) { traverseTree(node, spanId, segmentId, data) {
if (!node) { if (!node || node.isBroken) {
return; return;
} }
if (node.spanId === spanId && node.segmentId === segmentId) { if (node.spanId === spanId && node.segmentId === segmentId) {
......
...@@ -69,7 +69,7 @@ export default class Trace { ...@@ -69,7 +69,7 @@ export default class Trace {
L${d.target.y} ${d.target.x - 20} L${d.target.y} ${d.target.x - 20}
L${d.target.y} ${d.target.x - 5}`; L${d.target.y} ${d.target.x - 5}`;
} }
init(data, row) { init(data, row, fixSpansSize) {
d3.select('.trace-xaxis').remove(); d3.select('.trace-xaxis').remove();
this.row = row; this.row = row;
this.data = data; this.data = data;
...@@ -85,7 +85,7 @@ export default class Trace { ...@@ -85,7 +85,7 @@ export default class Trace {
if (d >= 1000) return d / 1000 + 's'; if (d >= 1000) return d / 1000 + 's';
return d; return d;
}); });
this.svg.attr('height', (this.row.length + 1) * this.barHeight); this.svg.attr('height', (this.row.length + fixSpansSize + 1) * this.barHeight);
this.svg this.svg
.append('g') .append('g')
.attr('class', 'trace-xaxis') .attr('class', 'trace-xaxis')
......
...@@ -101,6 +101,7 @@ limitations under the License. --> ...@@ -101,6 +101,7 @@ limitations under the License. -->
list: [], list: [],
currentSpan: [], currentSpan: [],
loading: true, loading: true,
fixSpansSize: 0,
}; };
}, },
watch: { watch: {
...@@ -108,7 +109,7 @@ limitations under the License. --> ...@@ -108,7 +109,7 @@ limitations under the License. -->
if (!this.data.length) { return; } if (!this.data.length) { return; }
this.loading = true; this.loading = true;
this.changeTree(); this.changeTree();
this.tree.init({label: 'TRACE_ROOT', children: this.segmentId}, this.data); this.tree.init({label: 'TRACE_ROOT', children: this.segmentId}, this.data, this.fixSpansSize);
this.tree.draw(() => { this.tree.draw(() => {
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false;
...@@ -124,7 +125,7 @@ limitations under the License. --> ...@@ -124,7 +125,7 @@ limitations under the License. -->
// this.loading = true; // this.loading = true;
this.changeTree(); this.changeTree();
this.tree = new Trace(this.$refs.traceList, this); this.tree = new Trace(this.$refs.traceList, this);
this.tree.init({label: 'TRACE_ROOT', children: this.segmentId}, this.data); this.tree.init({label: 'TRACE_ROOT', children: this.segmentId}, this.data, this.fixSpansSize);
this.tree.draw(); this.tree.draw();
this.loading = false; this.loading = false;
// this.computedScale(); // this.computedScale();
...@@ -136,7 +137,7 @@ limitations under the License. --> ...@@ -136,7 +137,7 @@ limitations under the License. -->
this.showDetail = true; this.showDetail = true;
}, },
traverseTree(node, spanId, segmentId, data) { traverseTree(node, spanId, segmentId, data) {
if (!node) { return; } if (!node || node.isBroken) { return; }
if (node.spanId === spanId && node.segmentId === segmentId) { if (node.spanId === spanId && node.segmentId === segmentId) {
node.children.push(data); node.children.push(data);
return; return;
...@@ -263,6 +264,7 @@ limitations under the License. --> ...@@ -263,6 +264,7 @@ limitations under the License. -->
segmentGroup[i.segmentId].push(i); segmentGroup[i.segmentId].push(i);
} }
}); });
this.fixSpansSize = fixSpans.length;
segmentIdGroup.forEach((id) => { segmentIdGroup.forEach((id) => {
const currentSegment = segmentGroup[id].sort((a, b) => b.parentSpanId - a.parentSpanId); const currentSegment = segmentGroup[id].sort((a, b) => b.parentSpanId - a.parentSpanId);
currentSegment.forEach((s) => { currentSegment.forEach((s) => {
......
...@@ -127,7 +127,7 @@ limitations under the License. --> ...@@ -127,7 +127,7 @@ limitations under the License. -->
this.showDetail = true; this.showDetail = true;
}, },
traverseTree(node, spanId, segmentId, data){ traverseTree(node, spanId, segmentId, data){
if (!node) return; if (!node || node.isBroken) return;
if(node.spanId == spanId && node.segmentId == segmentId) {node.children.push(data);return;} if(node.spanId == spanId && node.segmentId == segmentId) {node.children.push(data);return;}
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
for (let i = 0; i < node.children.length; i++) { for (let i = 0; i < node.children.length; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册