Skip to content

Commit 19171da

Browse files
committed
expand SVG to fit larger diagrams
1 parent 7350293 commit 19171da

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/Frontend/src/components/messages/SequenceDiagram.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const endpoints = ref<Endpoint[]>([]);
1515
const handlers = ref<Handler[]>([]);
1616
const routes = ref<MessageProcessingRoute[]>([]);
1717
const endpointCentrePoints = ref<EndpointCentrePoint[]>([]);
18+
const maxWidth = ref(150);
1819
const maxHeight = ref(150);
1920
const handlerLocations = ref<HandlerLocation[]>([]);
2021
@@ -35,6 +36,9 @@ fetchConversation();
3536
function setTimelines(centrePoints: EndpointCentrePoint[]) {
3637
endpointCentrePoints.value = centrePoints;
3738
}
39+
function setMaxWidth(width: number) {
40+
maxWidth.value = width;
41+
}
3842
function setMaxHeight(height: number) {
3943
maxHeight.value = height;
4044
}
@@ -44,15 +48,23 @@ function setHandlerLocations(locations: HandlerLocation[]) {
4448
</script>
4549

4650
<template>
47-
<svg class="sequence-diagram" width="100%" :height="maxHeight + 20">
48-
<Endpoints :endpoints="endpoints" @centre-points="setTimelines" />
49-
<Timeline :centre-points="endpointCentrePoints" :height="maxHeight" />
50-
<Handlers :handlers="handlers" :endpoint-centre-points="endpointCentrePoints" @max-height="setMaxHeight" @handlerLocations="setHandlerLocations" />
51-
<Routes :routes="routes" :handler-locations="handlerLocations" />
52-
</svg>
51+
<div class="outer">
52+
<svg class="sequence-diagram" :width="`max(100%, ${isNaN(maxWidth) ? 0 : maxWidth}px)`" :height="maxHeight + 20">
53+
<Endpoints :endpoints="endpoints" @centre-points="setTimelines" @max-width="setMaxWidth" />
54+
<Timeline :centre-points="endpointCentrePoints" :height="maxHeight" />
55+
<Handlers :handlers="handlers" :endpoint-centre-points="endpointCentrePoints" @max-height="setMaxHeight" @handler-locations="setHandlerLocations" />
56+
<Routes :routes="routes" :handler-locations="handlerLocations" />
57+
</svg>
58+
</div>
5359
</template>
5460

5561
<style scoped>
62+
.outer {
63+
max-width: 100%;
64+
max-height: calc(100vh - 27em);
65+
overflow: auto;
66+
}
67+
5668
.sequence-diagram {
5769
--error: red;
5870
--gray20: #333333;

src/Frontend/src/components/messages/SequenceDiagram/EndpointsComponent.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const props = defineProps<{
3636
3737
const emit = defineEmits<{
3838
centrePoints: [EndpointCentrePoint[]];
39+
maxWidth: [width: number];
3940
}>();
4041
4142
const epRefs = ref<SVGTextElement[]>([]);
@@ -72,12 +73,14 @@ const endpoints = computed(() =>
7273
})
7374
);
7475
75-
watch(endpoints, () =>
76+
watch(endpoints, () => {
7677
emit(
7778
"centrePoints",
7879
endpoints.value.map((endpoint) => ({ name: endpoint.name, centre: endpoint.x ?? 0, top: (endpoint.surround?.y ?? 0) + (endpoint.surround?.height ?? 0) + 15 }) as EndpointCentrePoint)
79-
)
80-
);
80+
);
81+
const lastEndpoint = endpoints.value[endpoints.value.length - 1];
82+
emit("maxWidth", (lastEndpoint.x ?? 0) + lastEndpoint.width);
83+
});
8184
8285
function setEndpointRef(el: SVGTextElement, index: number) {
8386
if (el) epRefs.value[index] = el;

0 commit comments

Comments
 (0)