Skip to content

Commit

Permalink
fix(UI): Add animation frames to plotly widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
rouk1 committed Oct 7, 2024
1 parent 32baec4 commit 02f7b77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions skore-ui/src/components/PlotlyWidget.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { newPlot, purge, relayout, type Layout } from "plotly.js-dist-min";
import { addFrames, newPlot, purge, relayout, type Layout } from "plotly.js-dist-min";
import { onBeforeUnmount, onMounted, ref } from "vue";
const props = defineProps<{
spec: { data: any; layout: any };
spec: { data: any; layout: any; frames: any };
}>();
const container = ref<HTMLDivElement>();
Expand All @@ -25,10 +25,13 @@ const resizeObserver = new ResizeObserver(() => {
}
});
onMounted(() => {
onMounted(async () => {
if (container.value) {
resizeObserver.observe(container.value);
newPlot(container.value, props.spec.data, makeLayout());
const plot = await newPlot(container.value, props.spec.data, makeLayout());
if (props.spec.frames) {
addFrames(plot, props.spec.frames);
}
}
});
Expand Down

0 comments on commit 02f7b77

Please sign in to comment.