fix width if no voter

This commit is contained in:
2025-06-01 12:12:59 +02:00
parent 3a2b20a4c4
commit b126226e61
4 changed files with 27 additions and 4 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
<template>
<div class="emphased">
<div v-for="(amount, val) in filtered_results" :id="`${questionId}-${val}`" :key="val"
:style="{ width: `${(amount / total) * 100}%`, background: colors[values.indexOf(String(val))] }">
:style="{ width: (total ? `${(amount / total) * 100}%` : '100%'), background: colors[values.indexOf(String(val))] }">
<span>({{ amount }}){{ val }}</span>
</div>
</div>
@@ -40,7 +40,7 @@ const filtered_results = computed(() => {
})
const total = computed(() => Object.values(filtered_results.value).reduce((acc, v) => v + acc, 0) ?? 1)
const total = computed(() => (Object.values(filtered_results.value).reduce((acc, v) => v + acc, 0) || 0))
</script>