fix stacks

This commit is contained in:
Fine 2024-12-03 17:51:11 +08:00
parent 5a4015dbba
commit 8c92c628a4

View File

@ -66,21 +66,27 @@ limitations under the License. -->
rateOfParent: "", rateOfParent: "",
}; };
countRange(); countRange();
for (const tree of ebpfStore.analyzeTrees) { if (props.type === ComponentType) {
const ele = processTree(tree.elements); const root = processTree(ebpfStore.analyzeTrees[0].elements);
root.children && root.children.push(ele); stackTree.value = root;
} else {
for (const tree of ebpfStore.analyzeTrees) {
const ele = processTree(tree.elements);
root.children && root.children.push(ele);
}
const param = (root.children || []).reduce(
(prev: number[], curr: StackElement) => {
prev[0] += curr.value;
prev[1] += curr.dumpCount;
return prev;
},
[0, 0],
);
root.value = param[0];
root.dumpCount = param[1];
stackTree.value = root;
} }
const param = (root.children || []).reduce(
(prev: number[], curr: StackElement) => {
prev[0] += curr.value;
prev[1] += curr.dumpCount;
return prev;
},
[0, 0],
);
root.value = param[0];
root.dumpCount = param[1];
stackTree.value = root;
const width = (graph.value && graph.value.getBoundingClientRect().width) || 0; const width = (graph.value && graph.value.getBoundingClientRect().width) || 0;
const w = width < 800 ? 802 : width; const w = width < 800 ? 802 : width;
flameChart.value = flamegraph() flameChart.value = flamegraph()
@ -165,9 +171,9 @@ limitations under the License. -->
obj[item.originId] = item; obj[item.originId] = item;
} }
const scale = d3.scaleLinear().domain([min.value, max.value]).range([1, 200]); const scale = d3.scaleLinear().domain([min.value, max.value]).range([1, 200]);
const condition = props.type === ComponentType ? "0" : "1";
for (const item of copyArr) { for (const item of copyArr) {
if (item.parentId === "1") { if (item.parentId === condition) {
const val = Number(scale(item.dumpCount).toFixed(4)); const val = Number(scale(item.dumpCount).toFixed(4));
res = item; res = item;
res.value = val; res.value = val;