This commit is contained in:
Fine 2025-04-08 18:52:36 +08:00
parent 77c1db0337
commit 0d07cac94e
2 changed files with 16 additions and 8 deletions

View File

@ -120,6 +120,7 @@ export default class ListGraph {
if (event.target === this) { if (event.target === this) {
d3.select("#trace-action-box").style("display", "none"); d3.select("#trace-action-box").style("display", "none");
t.selectedNode && t.selectedNode.classed("highlighted", false); t.selectedNode && t.selectedNode.classed("highlighted", false);
t.clearParentHighlight();
} }
}); });
} }
@ -406,14 +407,17 @@ export default class ListGraph {
callback(); callback();
} }
} }
clearParentHighlight() {
return this.root.descendants().map((node: { id: number }) => {
d3.select(`#list-node-${node.id}`).classed("highlightedParent", false);
return node;
});
}
highlightParents(span: Recordable) { highlightParents(span: Recordable) {
if (!span) { if (!span) {
return; return;
} }
const nodes = this.root.descendants().map((node: { id: number }) => { const nodes = this.clearParentHighlight();
d3.select(`#list-node-${node.id}`).classed("highlightedParent", false);
return node;
});
const parentSpan = nodes.find( const parentSpan = nodes.find(
(node: Recordable) => (node: Recordable) =>
span.spanId === node.data.spanId && span.spanId === node.data.spanId &&

View File

@ -144,6 +144,7 @@ export default class TraceMap {
if (event.target === this) { if (event.target === this) {
d3.select("#trace-action-box").style("display", "none"); d3.select("#trace-action-box").style("display", "none");
t.selectedNode && t.selectedNode.classed("highlighted", false); t.selectedNode && t.selectedNode.classed("highlighted", false);
t.clearParentHighlight();
} }
}); });
@ -404,14 +405,17 @@ export default class TraceMap {
that.update(d); that.update(d);
} }
} }
clearParentHighlight() {
return this.root.descendants().map((node: { id: number }) => {
d3.select(`#trace-node-${node.id}`).classed("highlightedParent", false);
return node;
});
}
highlightParents(span: Recordable) { highlightParents(span: Recordable) {
if (!span) { if (!span) {
return; return;
} }
const nodes = this.root.descendants().map((node: { id: number }) => { const nodes = this.clearParentHighlight();
d3.select(`#trace-node-${node.id}`).classed("highlightedParent", false);
return node;
});
const parentSpan = nodes.find( const parentSpan = nodes.find(
(node: Recordable) => (node: Recordable) =>
span.spanId === node.data.spanId && span.spanId === node.data.spanId &&