Skip to content

Commit fc76b3b

Browse files
committed
[#28] try to optimize digraph render
1 parent b894144 commit fc76b3b

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

components/ProfilerPageCallGraph/ProfilerPageCallGraph.vue

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { defineComponent, PropType } from "vue";
7373
import { Profiler, ProfilerEdge } from "~/config/types";
7474
import { addSlashes, DigraphBuilder } from "~/utils/digraph-builder";
7575
import debounce from "lodash.debounce";
76+
import destroy from "d3-graphviz/src/destroy";
7677
7778
export default defineComponent({
7879
components: { IconSvg },
@@ -92,7 +93,14 @@ export default defineComponent({
9293
};
9394
},
9495
created(): void {
95-
this.renderGraph();
96+
Graphviz.load().then(() => {
97+
this.graph = graphviz(this.$refs.graphviz, {})
98+
.width("100%")
99+
.height("100%")
100+
.fit(true);
101+
102+
this.renderGraph();
103+
});
96104
},
97105
beforeUnmount() {
98106
this.graph.destroy();
@@ -159,19 +167,15 @@ export default defineComponent({
159167
});
160168
},
161169
renderGraph(): void {
162-
Graphviz.load().then(() => {
163-
this.graph = graphviz(this.$refs.graphviz, {})
164-
.width("100%")
165-
.height("100%")
166-
.fit(true)
167-
.renderDot(
168-
new DigraphBuilder(this.event.edges).build(
169-
this.metric,
170-
this.threshold
171-
),
172-
this.nodeHandler
173-
);
174-
});
170+
this.graph
171+
.renderDot(
172+
new DigraphBuilder(this.event.edges).build(
173+
this.metric,
174+
this.threshold
175+
),
176+
this.nodeHandler
177+
)
178+
.resetZoom();
175179
},
176180
},
177181
});

0 commit comments

Comments
 (0)