Skip to content

Commit f9cb0b2

Browse files
committed
Fix - VueUiWordCloud - Fix reactivity when dataset changes
1 parent 3573abe commit f9cb0b2

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/components/vue-ui-word-cloud.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ const isDataset = computed({
5656
}
5757
});
5858
59-
const drawableDataset = ref(typeof props.dataset === 'string' ? createWordCloudDatasetFromPlainText(props.dataset) : props.dataset.map((dp, i) => {
60-
return {
61-
...dp,
62-
value: checkNaN(dp.value)
63-
}
64-
}));
65-
6659
const uid = ref(createUid());
6760
const step = ref(0);
6861
const wordCloudChart = ref(null);
@@ -81,6 +74,22 @@ const FINAL_CONFIG = computed({
8174
}
8275
});
8376
77+
const drawableDataset = ref(setupWordCloud());
78+
79+
function setupWordCloud() {
80+
return typeof props.dataset === 'string' ? createWordCloudDatasetFromPlainText(props.dataset) : props.dataset.map((dp, i) => {
81+
return {
82+
...dp,
83+
value: checkNaN(dp.value)
84+
}
85+
})
86+
}
87+
88+
watch(() => props.dataset, () => {
89+
drawableDataset.value = setupWordCloud();
90+
generateWordCloud();
91+
})
92+
8493
const { userOptionsVisible, setUserOptionsVisibility, keepUserOptionState } = useUserOptionState({ config: FINAL_CONFIG.value });
8594
const { svgRef } = useChartAccessibility({ config: FINAL_CONFIG.value.style.chart.title });
8695
@@ -436,7 +445,7 @@ function useTooltip(word) {
436445
:style="`width: 100%; font-family:${FINAL_CONFIG.style.fontFamily};background:${FINAL_CONFIG.style.chart.backgroundColor};${FINAL_CONFIG.responsive ? 'height:100%' : ''}`" @mouseenter="() => setUserOptionsVisibility(true)" @mouseleave="() => setUserOptionsVisibility(false)">
437446
<PenAndPaper
438447
v-if="FINAL_CONFIG.userOptions.buttons.annotator"
439-
:parent="wordCloudChart"
448+
:svgRef="svgRef"
440449
:backgroundColor="FINAL_CONFIG.style.chart.backgroundColor"
441450
:color="FINAL_CONFIG.style.chart.color"
442451
:active="isAnnotator"

0 commit comments

Comments
 (0)