Skip to content

Commit ba3eb4b

Browse files
committed
Fix - VueUiBullet - Fix config height & width not reactive; fix cropped legend in responsive mode
1 parent dcaa792 commit ba3eb4b

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

TestingArena/ArenaVueUiBullet.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ onMounted(async () => {
186186
<Box comp="VueUiBullet" :config="config" :dataset="dataset">
187187
<template #title>VueUiBullet</template>
188188

189-
<template #reponsive>
189+
<template #responsive>
190190
<div style="width: 600px; height: 600px; resize: both; overflow: auto; background: white">
191191
<LocalVueUiBullet :dataset="dataset" :config="{
192192
...config,
193193
responsive: true
194-
}" ref="local"/>
194+
}"/>
195195
</div>
196196
</template>
197197

src/components/vue-ui-bullet.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ function prepareChart() {
174174
source: source.value
175175
});
176176
177+
const legendOffset = FINAL_CONFIG.value.style.chart.legend.show ? 24 : 0;
178+
const offsetY = legendOffset || 12;
179+
177180
requestAnimationFrame(() => {
178181
defaultSizes.value.width = width;
179-
defaultSizes.value.height = height - 12;
182+
defaultSizes.value.height = height - offsetY;
180183
})
181184
});
182185
@@ -286,22 +289,25 @@ const { loading, FINAL_DATASET, manualLoading } = useLoading({
286289
const { userOptionsVisible, setUserOptionsVisibility, keepUserOptionState } = useUserOptionState({ config: FINAL_CONFIG.value });
287290
const { svgRef } = useChartAccessibility({ config: FINAL_CONFIG.value.style.chart.title });
288291
292+
const defaultSizes = ref({
293+
width: FINAL_CONFIG.value.style.chart.width,
294+
height: FINAL_CONFIG.value.style.chart.height
295+
});
296+
297+
const WIDTH = computed(() => defaultSizes.value.width);
298+
const HEIGHT = computed(() => defaultSizes.value.height);
299+
289300
watch(() => props.config, (_newCfg) => {
290301
if (!loading.value) {
291302
FINAL_CONFIG.value = prepareConfig();
292303
}
293304
userOptionsVisible.value = !FINAL_CONFIG.value.userOptions.showOnChartHover;
305+
defaultSizes.value.width = FINAL_CONFIG.value.style.chart.width;
306+
defaultSizes.value.height = FINAL_CONFIG.value.style.chart.height;
294307
prepareChart();
295308
titleStep.value += 1;
296309
}, { deep: true });
297310
298-
const defaultSizes = ref({
299-
width: FINAL_CONFIG.value.style.chart.width,
300-
height: FINAL_CONFIG.value.style.chart.height
301-
});
302-
303-
const WIDTH = computed(() => defaultSizes.value.width);
304-
const HEIGHT = computed(() => defaultSizes.value.height)
305311
306312
const svg = computed(() => {
307313
const height = HEIGHT.value;
@@ -550,7 +556,7 @@ defineExpose({
550556
<div
551557
ref="bulletChart"
552558
:class="`vue-data-ui-component vue-ui-bullet ${isFullscreen ? 'vue-data-ui-wrapper-fullscreen' : ''}`"
553-
:style="`font-family:${FINAL_CONFIG.style.fontFamily};width:100%;background:${FINAL_CONFIG.style.chart.backgroundColor}`"
559+
:style="`font-family:${FINAL_CONFIG.style.fontFamily};width:100%;background:${FINAL_CONFIG.style.chart.backgroundColor};${FINAL_CONFIG.responsive ? 'height:100%' : ''}`"
554560
:id="`bullet_${uid}`"
555561
@mouseenter="() => setUserOptionsVisibility(true)"
556562
@mouseleave="() => setUserOptionsVisibility(false)"

0 commit comments

Comments
 (0)