Skip to content

Commit

Permalink
Add error handling to shared vega wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jan 20, 2025
1 parent ff0240b commit 02a1433
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/src/components/Common/VegaWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div ref="chartContainer" :style="style"></div>
<b-alert v-if="errorMessage" class="p-2" variant="danger" show>
{{ errorMessage }}
</b-alert>
<div v-else ref="chartContainer" :style="style" />
</template>

<script setup lang="ts">
Expand All @@ -24,6 +27,8 @@ const style = computed(() => {
});
const chartContainer = ref<HTMLDivElement | null>(null);
const errorMessage = ref<string>("");
let vegaView: any;
async function embedChart() {
Expand All @@ -35,8 +40,9 @@ async function embedChart() {
const result = await embed(chartContainer.value, props.spec, { renderer: "svg" });
vegaView = result.view;
}
errorMessage.value = "";
} catch (e: any) {
console.error(String(e));
errorMessage.value = String(e);
}
}
Expand Down

0 comments on commit 02a1433

Please sign in to comment.